2

Is there any way to detect events, like swipe left or right, on the notification bar?

Prim
  • 21
  • 3

1 Answers1

0

See this http://stackoverflow.com/questions/14671453/catch-on-swipe-to-dismiss-event

It uses the DeleteIntent. DeleteIntent: DeleteIntent is a PendingIntent object that can be associated with a notification and gets fired when the notification gets deleted, ether by :

User specific action User Delete all the notifications. You can set the Pending Intent to a broadcast Receiver and then perform any action you want.

   Intent intent = new Intent(this,                  MyBroadcastReceiver.class);
  PendingIntent pendingIntent =     PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, 0);
   Builder builder = new Notification.Builder(this):

..... code for your notification builder.setDeleteIntent(pendingIntent); MyBroadcastReceiver

 public class MyBroadcastReceiver extends     BroadcastReceiver {
       @Override
       public void onReceive(Context context, Intent intent)      {
         .... code to handle cancel
          }

        }
code
  • 2,115
  • 1
  • 22
  • 46
  • Thanks, I actually saw that, but I am not interested in removal of a notification, or a notification status at any rate, I want to catch the exact swipe events with their directions. – Prim Jun 17 '15 at 10:02
  • Why do you want to know which direction it was swiped? – code Jun 17 '15 at 10:26
  • I want to add an action to the left swipe. – Prim Jun 17 '15 at 10:36