Skip to content

Instantly share code, notes, and snippets.

@uphy
Last active August 20, 2021 03:00
Show Gist options
  • Save uphy/7857256 to your computer and use it in GitHub Desktop.
Save uphy/7857256 to your computer and use it in GitHub Desktop.
Androidで、アクティビティではなく、アプリケーションレベルの再起動を行う。
final Intent i = new Intent(getApplicationContext(), ContentActivity.class);
final PendingIntent appStarter = PendingIntent.getActivity(getApplicationContext(), 0, i, 0);
final AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 5000, appStarter);
Process.killProcess(Process.myPid());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment