根据系统语言的变化来决定时候重新启动App
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
...
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
// check whether restart app or not
String saveLocal = PreferencesUtil.getInstance(this).getLocal();
String currentLocal = Locale.getDefault().getLanguage();
if (!currentLocal.equals(saveLocal)) {
PreferencesUtil.getInstance(this).saveLocal(currentLocal);
if (saveLocal != null) {
// Log.d("lpftag", "restart self");
Intent killIntent = new Intent(this,MainActivity.class);
killIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(killIntent);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
return;
}