我有一个应用程序,我在 webview 中加载 url。但是当我退出应用程序然后再次启动应用程序时,它会显示相同的页面。我希望每次应用程序启动时它都应该从主页开始。我该怎么做?这是我的 oncreate 方法:
web = (WebView) findViewById(R.id.webview01);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
web.getSettings().setLoadWithOverviewMode(true);
web.getSettings().setUseWideViewPort(true);
web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
web.getSettings().setPluginState(PluginState.ON);
web.getSettings().setJavaScriptEnabled(true);
web.setWebViewClient(new myWebClient());
这是 mywebclient 类:
public class myWebClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
if(url.startsWith("http://www.amazon.com/")) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
else{
view.loadUrl(url);
}
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
view.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
}
这里是 onresume():
@Override
protected void onResume() {
super.onResume();
web.setVisibility(View.INVISIBLE);
web.loadUrl("http://savebigshopper.com/maybelline");
}
请帮忙