Purpose: The notification should be automatically canceled by clicking and should open my activity (pending intent).
I have working code that works fine in Android Devices, expecting Nokia-X . Here is the code:
Notification notification = new NotificationCompat.Builder(MainActivity.this) .setContentTitle(MainActivity.this.getString(R.string.app_name)) .setContentText("text").setContentInfo("info").setTicker("Ticker text") .setContentIntent(contentIntent).setSmallIcon(R.drawable.ic_launcher).setWhen(System.currentTimeMillis()) .setLights(Color.YELLOW, 1, 2).setAutoCancel(true).build(); NotificationManager nm = (NotificationManager)MainActivity.this.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(1, notification);
In the case of a Nokia-x device, it sends a notification. It opens my activity when I click a notification, but the notification remains in the notification tray. It does not become clear when pressed.
Please help me!
source share