How can I close status bar after notification button click?
I tried this, but I had an exception:
java.lang.NoSuchMethodException: collapse []
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
...
My code:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle("Sync Failed")
.setContentText("Lorem ipsum dolor sit amet")
.setStyle(new NotificationCompat.BigTextStyle().bigText("Lorem ipsum dolor sit amet"))
.addAction(R.drawable.change, "Change Pass", pChangePass)
.addAction(R.drawable.remove, "Ignore", pIgnore)
.setAutoCancel(false);
mNotificationManager.notify(accountUnique, builder.build());
At NotificationIntent class
@Override
public void onReceive(Context context, Intent intent) {
int notificationID = intent.getExtras().getInt("NOT_ID");
this.callbackContext = StatusBarNotification.getCallback();
this.mNotificationManager = StatusBarNotification.getNotificationManager();
this.mNotificationManager.cancel(notificationID);
this.callbackContext.success(returnJSON(intent));
}
The following solution should be more simple and no non-public APIs used:
Ok, I solved it.