انجمن سایت کلیدستان


رتبه موضوع:
  • 1 رای - 3 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل ساخت نوتیفیکیشن در کلاس (در برنامه نویسی اندروید)

مشکل ساخت نوتیفیکیشن در کلاس (در برنامه نویسی اندروید)

#3
دوستان در همین رابطه من کد نوتیفیکیشن رو توی یه کلاس به نام Notif به صورت زیر نوشتم
این کد باید باعث بشه تا ده ثانیه دیر تر نوتیفیکیشن از کلاس Notif اجرا بشه

کد پی‌اچ‌پی:
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class 
Notif {

     public static 
void Notificationm(Context context){
         
NotificationManager nm=(NotificationManagercontext.getSystemService(Context.NOTIFICATION_SERVICE);
         
Notification notify=new Notification(R.drawable.ic_launcher,"شما یک پیام دارید",System.currentTimeMillis());
         
notify.flags |= Notification.FLAG_AUTO_CANCEL//Do not clear the notification
         
notify.flags |= Notification.FLAG_NO_CLEAR//Do not clear the notification
         
notify.flags |= Notification.FLAG_SHOW_LIGHTS//Do not clear the notification
         
notify.defaults |= Notification.DEFAULT_LIGHTS// LED
         
notify.defaults |= Notification.DEFAULT_SOUND// Sound
         
CharSequence title="Title";
         
CharSequence detils="Detils";
          
Intent nazar = new Intent(
                 
Intent.ACTION_VIEW,
                 
Uri.parse("http://cafebazaar.ir/"));
         
//Intent intent=new Intent(context,send.class );
         
PendingIntent pend=PendingIntent.getActivity(context0nazar0);
         
notify.setLatestEventInfo(contexttitledetilspend);
         
nm.notify(0,notify);
         
     }
    


و حالا میخوام با کد زیر توی Main Activity اجراش کنم

کد پی‌اچ‌پی:
new CountDownTimer(10000,1000){
             @
Override
             
public void onTick(long millisUntilFinished){}

             @
Override
                 
public void onFinish(){
                 
// your code
                 
                 
                 
                 
Notif.Notificationm(MainActivity.this);
                 
                 
             }
        }.
start(); 

ولی سر ده ثانیه Force Close میده........ مشکل رو چطور حل کنم؟؟؟؟
(دقت کنید که این کد بدون قسمت تاخییر به درستی اجرا میشه،،، فقط توی کد تاخیر که میذارمش force close میده)


پاسخ


پیام‌های این موضوع
RE: مشکل ساخت نوتیفیکیشن در کلاس - توسط kousha.nikkar - ۱۳۹۴/۰۱/۰۹, ۱۲:۱۳ ب.ظ
RE: مشکل ساخت نوتیفیکیشن در کلاس - توسط kousha.nikkar - ۱۳۹۴/۰۱/۰۹, ۰۱:۲۴ ب.ظ
RE: مشکل ساخت نوتیفیکیشن در کلاس - توسط admin - ۱۳۹۴/۰۱/۰۹, ۰۳:۳۲ ب.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان