Objective: Notification should be auto cancelled on click of it and should open my activity(Pending Intent)..
I have a running code which works perfect in Android Devices expect 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 case of Nokia-x device, It send notification. It open my activity on click of notification but notification stays in notification tray. It does not get clear on click.
Please help my out!!
It is just like Dr.Jukka said: Notifications cannot be programmatically removed from the Fastlane - only the user can remove content from the Fastlane:
"Currently all notifications are stored in the Fastlane even if the auto cancel flag is used. Do note that if your notification has a command visible from which user can dismiss/remove the notification manually, the notification is not removed from Fastlane. Notifications can only be removed from Fastlane manually by enabling the edit mode."
Furthermore, it does not make sense to have items such as notifications suddenly disappearing from the Fastlane since the purpose of the view is to display the user's/app's past activities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With