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


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

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

#1
سلام، من هرجوری سعی میکنم کد ایجاد نوتیفیکیشن رو توی کلاس نمیتونم بنویسم،
لطفاً راهنمایی کنید چه تغییری باید داد تا بتونم توی یک کلاس جدا و مخصوص به خودش بنویسمش

کد پی‌اچ‌پی:
public static void Notificationm(Context context,String Title,String Detils,String packge){
             
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/app/"+packge+"/?l=fa"));
             
//Intent intent=new Intent(context,send.class );
             
PendingIntent pend=PendingIntent.getActivity(context0nazar0);
             
notify.setLatestEventInfo(contexttitledetilspend);
             
nm.notify(0,notify);
         } 

یا این کد...

کد پی‌اچ‌پی:
NotificationCompat.Builder mBuilder =   new NotificationCompat.Builder(this)
.
setSmallIcon(R.drawable.ic_launcher// notification icon
.setContentTitle("Notification!"// title for notification
.setContentText("kelidestan.com"// message for notification
.setAutoCancel(true); // clear notification after click
Intent intent1 = new Intent(thisAkhbar.class);
PendingIntent pi PendingIntent.getActivity(this,0,intent1,Intent.FLAG_ACTIVITY_NEW_TASK);
mBuilder.setContentIntent(pi);
NotificationManager mNotificationManager =
            (
NotificationManagergetSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0mBuilder.build()); 


 
پاسخ


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

پرش به انجمن:


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