this is my first question here, I hope I'm not asking something repeated.
I'm making an Android app that consist in just a WebView. The problem is that onResume() doesn't load my web again. I have some external links that open other apps (the browser, the Twitter app, etc) and when I want to go back to my app it shows the background from the LinearLayout and it doesn't loads the WebView. I have the same problem when I lock the screen, it shows a blank screen (my background actually) after unlock.
It's my first time with Android so I can't figure how it all works, here is my code for onPause():
@Override
public void onPause() {
myWebView.setVisibility(WebView.GONE);
myWebView.destroy();
super.onPause();
}
And this is the code for onCreate(), I don't know if something else is relevant for this problem:
WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState);
if (!DetectConnection.checkInternetConnection(this)) {
Toast.makeText(getApplicationContext(), "No conn message", Toast.LENGTH_LONG).show();
myWebView = (WebView) findViewById(R.id.webView);
myWebView.setBackgroundColor(0);
myWebView.setBackgroundResource(R.drawable.background_wv);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setSupportZoom(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
} else {
myWebView.loadUrl(myURL);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.addJavascriptInterface(new WebAppInterface(this), "Android");
myWebView.setWebViewClient(new MyWebViewClient());
}
}
Thank you!
PS: I have no onResume code.