问题
这个问题是客户使用反馈回来的问题。我们的APP是机器开机后自启动的,按了home键后回到桌面,再打开APP,没有回到APP之前操作的页面,而是重新启动。
解决
修改APP启动页的onCreate()方法,如下:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!this.isTaskRoot()) {
Intent intent = getIntent();
if (intent != null) {
String action = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER)
&& Intent.ACTION_MAIN.equals(action)) {
finish();
return;
}
}
}
setContentView(R.layout.activity_launcher);
}
OK,解决问题!
(1)this.isTaskRoot();//判断是不是栈的根Activity
(2)注,在APP启动页,通常名为SplashActivity