RESTART ACTIVITY ONDESTROY ANDROID code example
Example 1: how to restart activity in android
restart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
recreate();
}
});
}
Example 2: restart application programmatically android
Intent mStartActivity = new Intent(context, StartActivity.class);
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);