a. 使用 FLAG_ACTIVITY_CLEAR_TOP :
Intent i = getBaseContext().getPackageManager ()
.getLaunchIntentForPackage (getBaseContext().getPackageName ())
i.addFlags (Intent.FLAG _ACTIVITY_CLEAR_TOP)
startActivity(i)
b. 使用 AlarmManager :
Intent intent = getBaseContext().getPackageManager ()
.getLaunchIntentForPackage (getBaseContext().getPackageName ())
PendingIntent restartIntent = PendingIntent.getActivity (getApplicationContext(), 0 , intent, PendingIntent.FLAG _ONE_SHOT)
AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM _SERVICE)
mgr.set (AlarmManager.RTC , System.currentTimeMillis () + 1000 , restartIntent)
System.exit (0 )
经过测试 发现两种都可以实现,但是当默认启动的activity的launchMode 设置为不是以”standard” 方式启动时,这个时候重启app不能清除activity中的内存数据。