I want a way to restart an app after the user has made any in-app purchase that removes ad banners, so that the onCreate()
methods gets called again.
The problem is, I don’t want any services to be killed, I just want the app to restart with changed restrictions
I found this code on Stack Overflow:
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);