在Android应用程序中启动Web浏览器发生错误

时间:2011-01-17 07:17:48

标签: android android-manifest

使用下面的代码我启动Web浏览器但不能

代码是:

Uri uriUrl = Uri.parse("www.google.com");
Intent launchBrowser = new Intent(Intent.ACTION_WEB_SEARCH, uriUrl);  
startActivity(launchBrowser);  
finish();

我还添加了menifest文件的互联网权限和字符串 错误是:意外关闭。 请

2 个答案:

答案 0 :(得分:6)

public class Webview extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Uri uri= Uri.parse("http://www.google.com");
        Intent intent=new Intent(Intent.ACTION_VIEW , uri);
        startActivity(intent);
}

此代码可以使用。

答案 1 :(得分:3)

尝试使用Intent.ACTION_VIEW代替Intent.ACTION_WEB_SEARCH