How to restart Android app in Android 10 after few seconds2020-05-23 android restart
I want to restart application after some seconds, following code worked in Android 8, but in Android 10 device nothing happens. Is ANY consideration is needed in Android 10? Here is the code worked in Android 8
Context mContext = getContext(); final int DELAY_I_WILL_BACK = 60; . . . Intent mStartActivity = new Intent(mContext, MainActivity.class); int mPendingIntentId = 123456; PendingIntent mPendingIntent = PendingIntent.getActivity(mContext, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + DELAY_I_WILL_BACK*1000, mPendingIntent); System.exit(0);
I tried mActivity.finishActivity(1); just before System.exit(0) but still does not working.
- How do I pass data between Activities in Android application?
- How do I "select Android SDK" in Android Studio?
- How to call a method after a delay in Android
- How do I shutdown, restart, or log off Windows via a bat file?
- How to get screen dimensions as pixels in Android
- How to stop EditText from gaining focus at Activity startup in Android
- Activity restart on rotation Android
- How to lazy load images in ListView in Android
- How do I display an alert dialog on Android?
- I am trying to set alarm on specific time using alarm manager but alarm initiated instantly?