문제

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 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top