Java – Android – open or restart the application after clicking the push notification using the flag activity
•
Java
I use push notifications in Android When I receive a push notification, if the application is still running, I want to open the application, otherwise I should open a new instance
I'm using it
PendingIntent contentIntent = PendingIntent.getActivity(this,notificationIntent,Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
However, when I received the push notification, I clicked it and there was no response
How can I do this by using flagintent?
Solution
You need to set the intent flag on the intent You specify them in the call to get pendingintent Try this:
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this,0);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码