Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Detail/Expanded Text from an Android Notification?

I've implemented a notification listener to look out for a Gmail notification.

I want to collect the expanded text (bigtext) from the notification as shown in the notification below:

Expanded text shown in gmail notification

See "----Forwarded message---", etc. which only appears when the user expands the notification to show the action buttons.

This string value does not appear in the notification's "EXTRAS" data...

http://developer.android.com/reference/android/app/Notification.html

like image 415
Rohan Avatar asked Dec 15 '22 00:12

Rohan


1 Answers

After viewing the above link, I further investigate the bundle (EXTRAS) data. When you debug it and look at the variable, you can find that all information regards the notification are stored in the bundle and you can get the detail by

notifyBundle.extras.getCharSequence("android.textLines") for multi line notification and

notifyBundle.extras.getString("android.text") for single line notification.

For more information, look at the variable in eclipse debugging mode

Image of variables in bundle for single line notification

Image of variables in bundle for multi line notification

Note: The extra bundle only available in API19 (Kitkat). I've never tried in device which lower than API19.

like image 183
ChiHang Avatar answered Dec 17 '22 13:12

ChiHang