그러냐

webview 새로고침현상 카메라로찍었을때 본문

android

webview 새로고침현상 카메라로찍었을때

관절분리 2017. 3. 6. 13:29
반응형

http://stackoverflow.com/questions/12131025/android-preventing-webview-reload-on-rotate


방법 1



41down voteaccepted

I think the main problem is that you call web.loadUrl(webURL); also when savedInstanceState != null

EDIT

Try:

if (savedInstanceState == null)
{
  web.loadUrl(webURL);
}

EDIT2: You also need the onSaveInstanceState and onRestoreInstanceState override.

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

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

  

방법 2


No java coding needed. use this in your manifest file.

 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"

like:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.Example.WebviewSample.webviewsample"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>        
</application>


반응형