Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何通过重新单击图标恢复应用程序状态和窗口?_Android - Fatal编程技术网

Android 如何通过重新单击图标恢复应用程序状态和窗口?

Android 如何通过重新单击图标恢复应用程序状态和窗口?,android,Android,如果我的应用程序最小化到后台,我发现它重新打开,而不是在我单击应用程序图标后恢复窗口及其状态。如何恢复它?我让它这样工作: 在manifest.xml活动部分添加了android:launchMode=“singleTask”,然后覆盖onNewIntent方法: @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(

如果我的应用程序最小化到后台,我发现它重新打开,而不是在我单击应用程序图标后恢复窗口及其状态。如何恢复它?

我让它这样工作: 在manifest.xml活动部分添加了
android:launchMode=“singleTask”
,然后覆盖onNewIntent方法:

    @Override
    protected void onNewIntent(Intent intent) {

        super.onNewIntent(intent);

        setIntent(intent);
    }

覆盖“onNewIntent”您需要首先了解活动生命周期,然后使用onSavedInstanceState保存所需状态,然后在再次打开时将其还原。此链接将帮助您