Issue
I ran into a strange problem today : I have 3 activites : A, B and C.
A starts B then finishes. B starts C then finishes. C is the only one running. And guess what happens when I call finish() on C (I have an exit app button) ? B is automatically created
So I did something : on B's onStart, if a certain static flag is set up, B call finish on itself. And what happened ? A was automatically created !
I finally got around that by calling finish() on A's start too if the flag is set but this was somehow a nightmare.
NB : I was 100% sure that C was the only one running when I pressed the exit button, thanks to logs on onDestroy() etc. I was also sure that there was no thread / timer running in the background etc. The proof is that A was magically created when I forced killed B, but was not created before.
NB 2 : I know the exit button is not the good thing on Android but the app is running in a kiosk on a special hardware support and users don't have access to home button and back arrow etc, hence the exit button in the admin part of the app
Edit :
// B.java:
xxx.onClick() { startActivityForIntent(B.this, C.class); finish();}
// same for A.java with B
// C.java exit.onClick { finish(); }
A is the entry point activity of the app
Solution
Ok. Apparently this behaviour is normal: Android wakes up the previous activity on the activity stack if you try to exit using finish(); this is because the OS wants your application to survive unexpected situations like phone-calls interrupting the user.
See this answer: Finish all previous activities.
Try adding android:noHistory="true" for all your activities in their xml files.
That, or try some of the methods mentioned in the answer above.
Answered By - vipluv
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.