Reputation: 569
I have something like this:
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://kwiatkowski.co/");
mWebView.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed() {
if(mWebView.canGoBack()) {
mWebView.goBack();
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Everything works only on the target site will be dynamic content and charts. How to make an application to reload page when you restore or I will come in application?
Upvotes: 3
Views: 4862
Reputation: 86
Use onResume void to make stuff when resuming app.
@Override
public void onResume() {
super.onResume();
mWebView.reload();
}
It will reload webview when resume.
Upvotes: 5