Conditional restart in Activity onConfigurationChanged

I want to make an action that allows you to change the orientation in some state, but not otherwise. More precisely, I want to prevent a restart of activity when the background thread is busy.

I put the attribute configChangesin the manifest of activity, and onConfigurationChangedis called when the orientation changes. However, I want to allow the application to change orientation , if allowed .

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (orientationChangeAllowed) {
        // how do I restart this activity?
    } else {
        // don't do anything
    }
}
+5
source share
1 answer

if he allowed the call setRequestedOrientation(), if he is not allowed, do nothing.

: onRetainNonConfigurationInstance() getLastNonConfigurationInstance() (, ) AsyncThread. , Activity , . : Context ( Activity Drawable,...).

+7

All Articles