当我尝试在第23.0.1版中点击我的通知时遇到问题,(我更新了最新版本)并且没有调用我的通知,我尝试了一些方法但没有工作。
我做错了什么?
long mId = System.currentTimeMillis();
Intent intent = new Intent(this, FragmentNotif.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
/*intent.setAction(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);*/
/*intent.putExtra("test","test1");*/
//PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent , PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent pendingIntent = PendingIntent.getActivity(context, (int)mId , intent , PendingIntent.FLAG_UPDATE_CURRENT);
pendingIntent.cancel();
//pendingIntent.FLAG_CANCEL_CURRENT;
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setWhen(mId)
.setLargeIcon(notificationLargeIconBitmap)//(R.drawable.icona_notificacio)
.setSmallIcon(getNotificationIcon())
.setContentTitle("XX XX")
.setContentText(data.getStringExtra("message"))
.setContentIntent(pendingIntent);
注意我的课程来自: GCMBaseIntentService
答案 0 :(得分:0)
您尝试更改源代码
nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
PendingIntent intent = PendingIntent.getActivity(
your main.this, (int)mId, new Intent(your main.this, your NotificationMessage.class), PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification;
notification = new Notification.Builder(.this)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(android.R.drawable.ic_input_add)
.setLargeIcon(bitmap).setWhen(System.currentTimeMillis())
.setSound(Uri.parse(
Environment.getExternalStorageDirectory().getPath()+"/.mp3"))
.build();
2. NotificationCompat.Builder
Notification = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(text)
.setTicker("Notification")
.setWhen(System.currentTimeMillis())
.setContentIntent(pendingIntent)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_launcher)
.build();
请参阅http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html