WebView mWebView=(WebView) findViewById(R.id.webView1);
mWebView.loadUrl("http://www.yuneach.com");在模拟器上,这个网页是在我自己的Activity上显示的,但是我把应用安装到手机上时,却弹出选择浏览器,然后是浏览器中显示了网页(脱离了我的Activity),请问这个怎么回事?
mWebView.loadUrl("http://www.yuneach.com");在模拟器上,这个网页是在我自己的Activity上显示的,但是我把应用安装到手机上时,却弹出选择浏览器,然后是浏览器中显示了网页(脱离了我的Activity),请问这个怎么回事?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// get the view web intent
Intent intent = this.getViewWebIntent();
this.printInterestedActivitiesByIntent(intent);
// set the className to use the specific browser to open the webpage.
intent.setClassName("com.tencent.mtt", "com.tencent.mtt.MainActivity");
startActivity(intent);
}
/*
*get the desired view web intent
*/
private Intent getViewWebIntent() {
Intent viewWebIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("http://www.2cto.com");
viewWebIntent.setData(uri);
return viewWebIntent;
}
定 单 号:6795224
mWebView1.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{ view.loadUrl(url); // 在当前的webview中跳转到新的url return true;
}
});
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView mWebView=(WebView) findViewById(R.id.webView1);
mWebView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{ view.loadUrl("http://localhost"); // 在当前的webview中跳转到新的url return true;
}
}); mWebView.loadUrl("http://localhost");
}