1
如果有人想看,我的项目有here。Android - 使用webView从活动1向活动2发送网址
所以,我想点击活动1上的图片(这是要举行链接),然后转到第二个活动与webview将打开该链接。我怎么做? 这是我对于当前的代码,但是当我点击图片崩溃的应用程序:
//Activity1.java
public void onClick(View view)
{
Bundle bundle = new Bundle();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
Intent act2 = new Intent(view.getContext(), Activity2.class);
String url = "http://www.google.com";
bundle.putString("urlString", url);
intent.putExtras(bundle);
startActivity(act2);
}
activity2.java:
//Activity2.java
//OnCreate
String url = super.getIntent().getExtras().getString("urlString");
mWebView = (WebView) findViewById(R.id.webView1);
mWebView.loadUrl(url);
private void load(String url)
{
mWebView = (WebView) findViewById(R.id.webView1);
mWebView.setWebViewClient(new WebViewClient());
mWebView.loadUrl(url);
}
随时检查出整个代码here 和感谢你提前。
谢谢,你又帮了我。 – 2014-09-04 09:29:02
在Webview上添加WebView客户端 – 2014-09-04 09:34:03
好的,我会的。它的导航,所以应用程序不打开网页浏览器 - 对吗? – 2014-09-04 09:37:14