title: How to programmatically restart an app in Android 10?
body: <p>I want a way to restart an app after the user has made any in-app purchase that removes ad banners, so that the <code>onCreate()</code> methods gets called again.</p>
  <p>The problem is, I don’t want any services to be killed, I just want the app to restart with changed restrictions</p>
  <p>I found this code on Stack Overflow:</p>
  <pre class="lang-java prettyprint-override"><code>Intent mStartActivity = new Intent(getApplicationContext(), MainActivity.class);
  int mPendingIntentId = 123456;
  PendingIntent mPendingIntent = PendingIntent.getActivity(getApplicationContext(), mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
  AlarmManager mgr = (AlarmManager)getApplicationContext().getSystemService(Context.ALARM_SERVICE);
  mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
  System.exit(0);
  </code></pre>