Select specific tab in TabActivity from PendingIntent sent from notification

I have a TabActivity with 4 tabs. I have a service that works - this service starts even after my TabActivity has been destroyed.

When the Service receives an event, I create a notification. Currently TabActivity can be destroyed or just run in the background.

How can I create a Notification / PendingIntent that will launch TabActivity if it is not currently running, or bring it to the forefront if it already exists and focus a specific tab based on the event?

I thought about registering the broadcast receiver from TabActivity programmatically, and with this I can focus the tab, but how can I activate the TabActivity active activity?

+3
source share
2 answers

I think I found the answer in the documentation

This is called for actions that set launchMode to singleTop in their package, or if the client used the flag in the call . In any case, when an activity is restarted at the top of the action stack instead of a new instance of the operation to be launched, it will be called in the existing instance with the intention that was used to restart it " FLAG_ACTIVITY_SINGLE_TOPstartActivity(Intent)onNewIntent()

This solves the problem that I was trying to find out that the Intent was not passed onCreate when the application was already running, because onCreate () was not called.

+1
source

, " " " Activity from notification" - , ) , " " PendingIntent. , , , "onCreate()" Activity, Intent ( Activity getIntent()) setCurrentTab (); tabHost.

) , .

+2

Source: https://habr.com/ru/post/1734370/


All Articles