Read Content From Notification Parcelable Objects For Consequent Notification
I am trying to build Whatsapp Notification filtering app, where I monitor all notification from Whatsapp and remove messages as per filtering policy. I can fetch message content us
Solution 1:
Yes, finally after few hours of googling I design a code which does work for me.
Bundle extras = sbn.getNotification().extras;
CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
JSONArray s = newJSONArray();
for (CharSequence msg : lines) {
msg = removeSpaces(msg);
if (!TextUtils.isEmpty(msg)) {
s.put(msg.toString());
}
}
privatestaticStringremoveSpaces(@Nullable CharSequence cs) {
if (cs == null)
returnnull;
Stringstring = cs instanceofString ? (String) cs : cs.toString();
returnstring.replaceAll("(\\s+$|^\\s+)", "").replaceAll("\n+", "\n");
}
here JSONArray s contains all messages that I want
Post a Comment for "Read Content From Notification Parcelable Objects For Consequent Notification"