0

I have a problem when I try click my notification in versión 23.0.1, (I updated latest version) and my notification not is called, I tried some methods but not work.

What I do wrong ?

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);

Note my class extends from : GCMBaseIntentService

1 Answers1

0

you try change to source code

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();

Please refer to http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html

  • your code is exactly same that my code, and I need use "NotificationCompat.Builder" –  Nov 02 '15 at 09:34