Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid blank WebView after Application Restart
    primarykey
    data
    text
    <p>I have a problem with my WebView. When I start the Application with Eclispe it works fine on my Device (Samsung Galaxy S2, Android 4.1.2/API 16). It loads the Website I've passed with webview.loadUrl('my url'); and also graps some javascript alerts and stuff. When I leave the application an restart it, it only works once more. When I restart the App second time it wont load any URL. I guess that it has something to do with savedInstanceState, but even if I set that Bundle to null at the very beginning of the Activities, it does not reload the URL.</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { savedInstanceState=null; super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); browser = (WebView) findViewById(R.id.browser); ... browser.loadUrl(url); } </code></pre> <p>I also tried to remove all Cookies with</p> <pre><code> CookieSyncManager.createInstance(this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); </code></pre> <p>Still having the same Bug. I allready read much solved posts and questions about WebView in Android, but nothing helped. Does anyboby have any idea? I am confused...</p> <p>Whole onCreate Method:</p> <pre><code>@SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { savedInstanceState=null; super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); browser = (WebView) findViewById(R.id.browser); // if (savedInstanceState != null) { // browser.restoreState(savedInstanceState); // } /* JavaScript must be enabled if you want it to work, obviously */ browser.getSettings().setJavaScriptEnabled(true); final Context myApp = this; final Communicator c = new Communicator(); /* WebChromeClient must be set BEFORE calling loadUrl! */ browser.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) { Log.d(TAG, "onJsAlert"); try { JSONObject json = new JSONObject(message); if (json.has("func")) { if (json.getString("func").equals("onUserInfos")) { c.onUserInfos(json); Log.d(TAG, "JSON verarbeitet"); } } return true; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO Log.v(TAG, "JavaScript Alert empfangen"); new AlertDialog.Builder(myApp) .setTitle("javaScript dialog") .setMessage(message) .setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.confirm(); } }).setCancelable(false).create().show(); return false; }; }); // Reset all Cookies CookieSyncManager.createInstance(this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); /* load a web page which uses the alert() function */ String url = c.getGuiURL(); browser.loadUrl(url); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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