I am trying to refresh the contents of an activity on click of a notification. I can navigate to the activity when I am in some other activity and I click on the notification. What I am trying to achieve is, I am in Activity A which is displaying some content. I get a new notification, I click on it Activity A should either be relaunched or the content in the activity should be refreshed with respect to what I am passing in the PendingIntent of the Notification.
What all I have done,
Tried setting PendingIntent.FLAG_CANCEL_CURRENT
and PendingIntent.FLAG_UPDATE_CURRENT
Tried setting Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP
in the intent I am passing along with the pending intent.
Checked the data in onNewIntent()
its doesn't get refreshed. I get the same data which I have passed in the old intent.
Passed a unique requestCode
along with the PendingIntent as well, still the same.
Any Other suggestions?
How to restart an Activity in Android? This example demonstrates how do I restart an Activity in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code ...
Auto Refresh With Notifications will help you automatically refresh on one page until "Excludes" contents are not shown on the page. You will be notified loudly with sounds which are set in...
This example demonstrates how to reload activity in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml.
When a device requires a restart, the client shows a notification to the end user of the upcoming restart. Toast notification A Windows toast notification informs the user that the device needs to restart.
If you use Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
, this should recreate the activity if it was in the stack, or start a new activity if it wasn't in the stack. If you don't want the activity to be recreated (if it is already in the stack), you can use Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With