java - Launching existing Activity on Notification click -
There is a countdown timer created on one piece. If the countdown timer is running, then the user can navigate inside the app or go outside of the app. Whenever the user goes outside the countdown timer, there should be a notification at the top. If the user clicks on notification, then they should be directed to the CountTownTimer piece and the timer's correct number should be shown below. Opens the code activity below, in which a counterdown timer has been created. But it launches a new example of that activity. Is there any way to get an old example of the same activity so that I can start the activity again from the previous situation?
{Notification. Builder Note = New Notification. Builder (getActivity ()); Noti.setContentTitle ("Kick Counter"). SetSmallIcon (R.drawable.mom_ic_launcher) .setAutoCancel (true); Intent notification intent = new intent (getActivity (), kick-quatactivity.class); NotificationIntent.addFlags (Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); Pending Content ContentIntent = PendingActivity (getActivity), 0, Notification Notification, Pending Provider.FLAG_UPDATE_CURRENT); Noti.setContentIntent (contentIntent); Notification Manager Notifier = (Notification Manager) getActivity (). GetSystemService (reference .NETIFICATION_SERVICE); Notifier.notify (1, noti.build ()); }
intent
- Take a look at the flag. I am doing this like this:
last intention openActivityIntent = new intent (reference, MainActivity.class); OpenActivityIntent.setAction ("YOUR_ACTION"); OpenActivityIntent.addFlags (Int. FLAG_ACTIVITY_CLEAR_TOP | Intent. FLAG_ACTIVITY_SINGLE_TOP | Intent. FLAG_ACTIVITY_NEW_TASK); Context.startActivity (openActivityIntent);
In your activity, you will receive action if you have registered it as a listener and acted upon it, e.g. Navigate your timer If you want additional data, you can add it to openActivityIntent.putExtras (bundle)
Comments
Post a Comment