Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dont reload webview video on rotate

I have a webview that is showing an embedded video. When the device is rotated, I can prevent the entire page from being reloaded with:

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    webView.saveState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    webView.restoreState(savedInstanceState);
}

However, since I am playing a video in this webview, the video does not continue playing. Instead, it will load the video as if it has not started playing. How can I rotate the screen but continue the video like nothing happened?

Thanks

like image 670
Nick Avatar asked Sep 06 '12 16:09

Nick


1 Answers

Add this in manifest.xml

 upto API level 12

       <activity
            android:label="@string/app_name"
            android:name="Activity"
            android:configChanges="keyboardHidden|orientation">
 </activity>

after apl level 12,

       <activity
            android:label="@string/app_name"
            android:name="Activity"
            android:configChanges="keyboardHidden|orientation|screenSize">
      </activity>
like image 193
Rajendra Avatar answered Nov 06 '22 12:11

Rajendra