android 进程自杀再重启的方法

PendingIntent restartIntent = PendingIntent.getActivity(mContext, -1, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager almgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
if (almgr != null) {
    almgr.set(AlarmManager.RTC, System.currentTimeMillis() + 20, restartIntent);
} else {
    Log.e(TAG, "get alarm_service return null");
}

if (Log.enabled)
    Log.d(TAG, "to kill self");
mContext.finish();
Process.killProcess(Process.myPid());
mContext属于某个Activity.
参考:
http://blog.csdn.net/cym_lmy/article/details/24704089
ActivityManager.restartPackage(packageName);

你可能感兴趣的:(android)