Android opens the app again and enters the interface when pressing the home key to exit (thistaskroot)

After the startup mode of the Android settings page is singletask, when you press home to exit, reopen the application and enter the first startup page. This will cause some applications to need to log in again, and the current page data will be lost

Although we have solved the problem, we should also analyze the ideas to solve the problem.

Hahaha, maybe you say the idea is Baidu. Others write like this. Anyway, I used it and succeeded. (but we want to develop in the direction of excellent programmers)

The second line: this. Istaskaroot () determines whether it is the bottom of the activity stack

The third line: getintent () gets the information of the intent passed from the previous page. Because in the startup page, we will set

Line 6: judge whether to start through the startup page, or it may be the demand jump in the code. In this case, the page cannot be destroyed.

Line 7: destroy the current startup page

[thinking] so why finish if it is started externally?

Reference 1: https://www.jianshu.com/p/eea14ca0b164

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>