I am working on an android app where I need to get incoming message from whatsapp or any other chatting app and then reply to that message using my app.
I am able to extract message and other data from notification using NotificationListener Service, but I don't know how to reply to that notification from my app.
I got all the information using the following method of NotificationListener Class.
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
Intent intent = new Intent(this, ChatHeadService.class);
startService(intent);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
String key = sbn.getKey(); // notification key
PendingIntent intent1 = sbn.getNotification().contentIntent; // pending intent
String pack = sbn.getPackageName(); // package name of app
Bundle noti = sbn.getNotification().extras; // extra bundle of notification
String name = noti.getString("android.title"); // name of the sender
Bitmap img = sbn.getNotification().largeIcon; // the icon of the sender user
CharSequence[] textlines = noti.getCharSequenceArray("android.textLines");
if (textlines != null)
Log.i("textlines", textlines.toString());
Now I need to reply to the above notification!