I want to get message from Whatsapp.I can whatsapp message but how to get received telephone number from Whatsapp Notification?
My code in NotificationListener;
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
Intent broadcastIntent =new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
OpenNotification(sbn.getNotification().extras.toString());
if (sbn.getPackageName().equals(WHATSAPP_PACK_NAME) && isRecordStart) {
Bundle bundle = sbn.getNotification().extras;
String fromContact = bundle.getString("android.title");
String messageText = bundle.getString("android.text");
String pushTel = ""// HOW CAN I GET THE NUMBER FROM WHATSAPP?
String text = bundle.getCharSequence("android.text").toString();
System.out.println("whatsapp messageText :"+messageText+" text:"+text+" fromContact:"+fromContact+" pushTel:"+pushTel);
if (fromContact.equals("WhatsApp")) {
return;
}
Toast.makeText(this, ""+messageText.toString(), Toast.LENGTH_SHORT).show();
broadcastIntent.putExtra("key_whatsapp_Content", messageText);
LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);
}
}