简体   繁体   English

如何在本机浏览器(Android)中打开URI

[英]How to open URI in the native browser (android)

I want to open the page ya.ru in the native browser. 我想在本机浏览器中打开页面ya.ru。 That's what I have 那就是我所拥有的

list.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        // TODO Auto-generated method stub
        String url = "http://ya.ru"; 
        Intent intent1 = new Intent(Intent.ACTION_VIEW);
        intent1.setData(Uri.parse(url));
        startActivity(intent1);
    }
});

Could you tell me what I should write in uses-permissions except 你能告诉我我应该在uses-permissions写些什么,除了

<uses-permission android:name="android.permission.INTERNET" />

or is there anything wrong in the code? 还是代码有什么问题?

Try 尝试

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.ya.ru"));
startActivity(intent);

And in AndroidManifest.xml you have to write: 在AndroidManifest.xml中,您必须编写:

<uses-permission android:name="android.permission.INTERNET" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM