Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.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_Android Intent - Fatal编程技术网

使用意图标志重新启动android应用程序

使用意图标志重新启动android应用程序,android,android-intent,Android,Android Intent,在发生语言更改时,我只想重新启动android应用程序以反映ui更改,因此以下是我的代码: Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK

在发生语言更改时,我只想重新启动android应用程序以反映ui更改,因此以下是我的代码:

Intent i = getBaseContext().getPackageManager()
                  .getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
startActivity(i);
这对android棒棒糖和果冻豆很好,但对kitkat不起作用

Android:launchMode=“singleTask”

可能重复的