I have a activity that displays a number of elements from a list that the user can scroll through. In addition from navigating the list for 开发者_JS百科new elements added the user can click a popup notification to immediately goto that element. I only ever want one instance of the list running so I made it a SingleInstance. Unfortunately that means if a user clicks the notification it ignores the startActivity() instead of jumping to that element.
My question is, is there a way I can make the notification either start the activity (bundled with which item to view) if it isn't up and if it is, receive the bundle and act on it?
Cheers!
If you want an activity to only have one instance of it running, mark it with android:launchMode="singleTop"
in the manifest. This will cause Android to create the activity (if it doesn't exist) and call onNewIntent(Intent)
on the activity. From the caller's perspective, you simply fire off the intent as normal.
精彩评论