4
I made this in my app:
onCreate:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ...
instances:
@Override protected void onSaveInstanceState(Bundle outState){ super.onSaveInstanceState(outState);//Salva Activity siteWebView.saveState(outState);//Salva WebView } @Override protected void onRestoreInstanceState(Bundle savedInstanceState){ super.onRestoreInstanceState(savedInstanceState);//Restaura o Activity siteWebView.restoreState(savedInstanceState);//Restaura o WebView }
And in the manifest I used:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.foo.bar">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
I’ll try it, I like the tip from
@TargetApi
, help with other tasks (although I will only be creating apps for android4.2), thanks for the time being– Guilherme Nascimento
Take a test, man, see how best it fits you, maybe it doesn’t help and you have to opt for configChanges, but hopefully it works! Hugs!
– Carlos Bridi
If you put the Log. i() in onResume, onCreate, it triggers those methods even with the configChanges()?
– Carlos Bridi
I had this problem for some time, and remember that at the time it was not necessary for the project to have screen in Landscape. Test with @Targetapi. Ah, but when you put the configChanges, did you put it in your Activity or in the general Activity of the project? Try to put in a part Activity.
– Carlos Bridi
I tested it more carefully and it worked, the only thing I added was the
"keyboardHidden|orientation|screenSize"
, see in my question, I missed the spot, the correct was to add<activity ...>
, but for lack of attention I added in<Android ...>
, thank you Carlos.– Guilherme Nascimento