I\'m trying to detect when my notification gets cleared. My question directly refers to this answer which outlines what I\'m suppose to do. This is how I\'m implementing the
sample code which will be called whenever user clears the notification, hope it will help you .
....
notificationBuilder.setDeleteIntent(getDeleteIntent());
....
protected PendingIntent getDeleteIntent()
{
Intent intent = new Intent(mContext, NotificationBroadcastReceiver.class);
intent.setAction("notification_cancelled");
return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
}
NotificationBroadcastReceiver.java
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if(action.equals("notification_cancelled"))
{
// your code
}
}
AndroidManifiest.xml