In my notification listener, I m not able to get value for keyvalue
[android.text]
when the notifications are received from gmail. It is working fine for most of notifications, but for gmail, it throws exception as below.
W/Bundle: Key android.text expected String but value was a android.text.SpannableString. The default value <null> was returned. W/Bundle: Attempt to cast generated internal exception: java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String
Below is how i m fetching value of text
String rawmessage = bundle.getString("android.text");
since we do not have any method for extracting SpannableString from bundle, can someone help to handle this.
Advertisement
Answer
just try this–>
String rawmessage = bundle.getCharSequence("android.text");
Or try it like this–>
SpannableString a = (SpannableString) bundle.getCharSequence("android.text"); yourview.setText(a)