[java]
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
ps:
getApplicationContext()返回應用的上下文,生命周期是整個應用,應用摧毀它才摧毀
Activity.this的context 返回當前activity的上下文,屬於activity ,activity 摧毀他就摧毀
getBaseContext() 返回由構造函數指定或setBaseContext()設置的上下文