Question

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!!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top