I am trying to save an instance of StatusBarNotification
, so that i could show the notification later to the user. I noticed that StatusBarNotifcation
is not Serializable
but Parcelable
. Is there any way to store the exact instance state in the database so that even if user turns of his phone, the instance object is stored.
I know its not the best practice to store the Parcelable
object in database. But I need to do it.
If there is any way i could get the byte array of the instance, I am open for suggetions.
EDIT
I found out today that, if I turn off my android phone with some un-attended notification, when I restart my phone I am still able to see the same notifications. That being said, android is somehow saving the same instance of notification.
Now my question is, how?? And if android does why can't us.
I think you cannot save the parcelable object of notification in the database (also not a good practice).
No. In particular, not only do you have no way of persisting the
PendingIntents
associated with theNotification
, but you have no way of recreating them with all the security rules intact. APendingIntent
is tied closely to the app that creates it; you are not the app that created thosePendingIntents
originally.