重新启动应用程序,以一定的活动? [英] Restart app to a certain activity?

查看:139
本文介绍了重新启动应用程序,以一定的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重新启动我的应用程序有一定的活动......这可能吗?

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.

推荐答案

在这第一次启动,你需要检查,如果你想要去到另一个活动活动的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

在这里重新开始一些条件检查,如果你的应用程序在运行前,您可以使用共享preferences存储一些布尔值

where restarted is some condition that check if your app was running before , you can use shared preferences to store some bool value

if(restarted){

        Intent startActivity = new Intent();
        startActivity.setClass(this,OTHER_ACTIVITY.class);
        startActivity(startActivity); 
        finish();
}else{
   //just normal flow
}

这篇关于重新启动应用程序,以一定的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆