- 方法一 利用PackageManager类
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage( getBaseContext().getPackageName() )
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(i)
- 方法二 利用PendingIntent
int mPendingIntentId = 123456
PendingIntent mPendingIntent = PendingIntent.getActivity(context, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT)
AlarmManager mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE)
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent)
System.exit(0)