开发者

How to kill an app?

I have an app with more than 4 activities, but when somebody wants to exit the app, he gets all the activities again. Now i've tried to use exit codes:

this.fini开发者_运维技巧sh()
android.os.Process.killProcess(android.os.Process.myPid())

etc.

But nothing helps me, so my question is, is there an way to kill all the activities at one time, like a task killer?

Edit:

I've found it on myself:

When you launch the second activity, finish() the first one immediately:

startActivity(new Intent(...));
finish();


Does System.exit(0) do the trick?


Try getParent().finish() where you catch the back button; getParent() returns the activity that called current activity. And if you finish the parent, you finish the child. Also you can make start the activities for result and then pass something in the intent data on which you'll test and finish each activity one by one. I'm not sure if this is the best and working solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜