Note that there are some explanatory texts on larger screens.

plurals
  1. POMinimizing the app, changing language and resuming calls onCreate() instead of onResume()
    primarykey
    data
    text
    <p>I just noticed a weird issue I've been having in my app. When I'm running my app, if I minimize it, then go the settings and change the language, then resume my app(note: this is minimize/resume, not exit/start), it calls the Activity's <code>onCreate()</code> instead of calling <code>onResume()</code>.</p> <p>This is causing a lot of issues, especially in areas where I'm using fragments in the view. The fragments being displayed are the old fragments, but the activity reference they are holding is <code>null</code>. So <code>getActivity()</code> doesn't work immediately after resuming, causing <code>NullPointerException</code> in many places.</p> <p>My app is being built for Android 4.0.4 and above and I've noticed this issue on different devices and emulators, so it's not a platform issue.</p> <p>Ideally, I'd like to call <code>onResume()</code> as it's supposed to. If not, I'd prefer to have the application relaunch itself silently and land the user on the home screen instead of having to face an App crash.</p> <p>The app itself supports just one language: English(USA).</p> <p>Has anyone faced this issue before? If yes, could you manage to resolve it?</p> <p>EDIT: Based on Class Stacker's answer, It seems I need to handle the configuration change myself. Which should be fine, except that an exception is thrown in the <code>onCreate()</code> itself. I am calling <code>getWindow().setRequestFeature(Window.FEATURE_INDETERMINATE_PROGRESS)</code> in the <code>onCreate()</code>. When the locate changes, this line is throwing a <code>RuntimeException</code> saying that this must be called before <code>setContentView()</code>.</p> <p>Does this mean my Activity is not getting destroyed properly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload