重新启动应用程序以进行特定活动?
我需要重新启动我的应用程序以进行特定活动...可能吗?
当我重新启动它时,我不想启动应用程序的第一个活动。我该怎么做?
编辑:当我重新启动应用程序时,我需要释放应用程序的内存。
I need to restart my app to a certain activity...is it possible?
When I restart it I don't want to start the first activity of application. How can I do this?
EDIT : I need to free memory of the app when I restart the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在第一次启动的活动的 onCreate 方法中,您需要检查是否要转到另一个活动,然后
重新启动是检查您的应用程序之前是否运行过的一些条件,您可以使用共享首选项来存储一些布尔值价值
In the onCreate method of the activity that is first launched you need to check if you want to go to another activity or not and then
where restarted is some condition that check if your app was running before , you can use shared preferences to store some bool value
您必须直接从初始
Activity
的onCreate()
启动您想要的Activity
。由于这仅在应用重新启动时适用,因此您必须保存SharedPreference
来标记您的应用已经启动过一次的事实。不会出现任何闪烁,因为
Activity
的设计方式是,如果在onCreate()
期间启动另一个Activity
,则不会显示该闪烁。You have to start the
Activity
you wish straight from the initialActivity
'sonCreate()
. As this is only applicable when the app restarts, you have to save aSharedPreference
to flag the fact your app has already started once.There won't be any flickering as
Activity
is designed in a way it is not displayed if anotherActivity
is started during itsonCreate()
.