Retrieving SpannableString
If you cannot control what is put in the intent extras you should be able to retrieve it with the following code:
val msg = sbn.notification.extras.getCharSequence("android.text").toString()
Note that SpannableString
class extends CharSequence
.
Adding extras
Wherever you are adding the extras make sure that you do not add a SpannableString but the string itself!
For example, for an editText:
var editText: EditText = ...
extras.put("android.text", editText.text) // this will put an Editable which is a Spannable and not a string
extras.put("android.text", editText.text.toString()) // this puts a string
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…