Issue
I have my app to carry out a notification when a given condition occurs.
The target intent is the main class Activity of my App.
If I click on the notification in the drawer and my App is already running, a new instance of the class is created (I can tell it is a new class from the debugger for one thing).
When the newly created window appears it is showing as my App when I look at the tasks running, but is the only instance of that App.
What happened to the original instance of my Activity class, and what happened to the original instance of the App?
Can I be sure there is only one instance of the Activity running ?
Thanks
Solution
1) The original instance should still be there, but in the backstack. You should be able to reach it via the back button. https://developer.android.com/guide/components/activities/tasks-and-back-stack.html
2) Mark Keen's answer is correct here -- use android:launchMode="singleInstance" for the tag of your activity in your android manifest. https://developer.android.com/guide/topics/manifest/activity-element.html
Answered By - Karl Jamoralin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.