Android Open Activity And Close Previous One

送分小仙女□ 提交于 2019-12-13 12:37:47

问题


Alright so I have a loader screen which fetches files and what not, things the app needs to function and then when it's done loading it starts the main activity. However when you press back it goes back to the loading activity which obviously i don't want.

Solution I set this in the manifest android:noHistory="true" for the loading screen activity. But there is an issue with this, my application is a root app so it needs superuser permissions in the loader screen and when the su dialog appears asking to accept or decline the loading screen closes since history is off and another app has taken the view. I have found that if i remove noHistory from the manifest su doesn't close my app so i know that's what it is.

So the final question then is, is there a flag or something i can set on the intent to keep the loader out of history when the intent is launched at the end after we've gained superuser permissions cause i need to keep the loader open when superuser comes up but don't want it there when the user hits back

Thank you for any help


回答1:


Finish the activity after starting the new one.

startActivity(intent);
finish();


来源:https://stackoverflow.com/questions/7706106/android-open-activity-and-close-previous-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!