Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid setting Orientation locked the orientation
    text
    copied!<p>I need to play the embedded videos in webview in normal orientation(as the webview is, such as PORTRAIT or LANDSCAPE), and force into LANDSCAPE mode in fullscreen video. So I did as the following steps:</p> <ol> <li>change the Activity's config in manifest file to <code>android:configChanges="keyboardHidden|orientation|screenSize"</code>. </li> <li><p>in the WebView's WebChromeClient class,</p> <pre><code> @Override public void onShowCustomView(View view, CustomViewCallback callback) { LogUtil.d(TAG, "onShowCustomView"); super.onShowCustomView(view, callback); mHandler.post(new Runnable(){ @Override public void run() { Activity activity = getActivity(); if(activity == null){ return; } activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } }); } @Override public void onHideCustomView() { super.onHideCustomView(); mHandler.post(new Runnable(){ @Override public void run() { Activity activity = getActivity(); if(activity == null){ return; } activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }); } </code></pre></li> </ol> <p>;; After doing this, generally it works fine. But it has one fault: before playing the video in fullscreen, the activity/fragment can rotate according to the phone direction, but after i return from fullscreen(LANDSCAPE mode) to embedded(PORTRAIT mode), the activity/fragment never change its orientation. How can i handle this case? i just want to restore to the original state, not lock the orientation. Thanks</p>
 

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