Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear notification from notification tray on click in nokia-x

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

like image 679
Kapil Avatar asked Jun 05 '14 11:06

Kapil


1 Answers

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.

like image 101
Tomi Paananen Avatar answered Nov 15 '22 00:11

Tomi Paananen