Can I call recreate()
in onDestroy()
method of MainActivity
? The idea is to restart the activity whenever OS stops it. Is it possible and are there any disadvantages of doing this. Basically, I have a blank activity that starts many services, but the app stops unexpectedly (due to which all services too stops) on one of the manufacturer (while it works fine for most of the phones). For instance something like this is possible?
public void onDestroy()
{
super.onDestroy();
this.recreate();
}
UPDATE 1 Restart the main activity after 2 hours, any suggestion to this approach. Is it bad, since main activity will call itself again.
Intent ishintentC = new Intent(this, MainActivity.class);
PendingIntent pintentC = PendingIntent.getService(this, 0, ishintentC, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmC = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarmC.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+7200000,AlarmManager.INTERVAL_HOUR*2, pintentC);