How to open default browser

后端 未结 2 607
耶瑟儿~
耶瑟儿~ 2021-01-16 13:51

I want to make somethink like hyperlink. Right now, i created button, which opens new Activity with WebView. But i want to open a \"globally\" default web browser at specifi

相关标签:
2条回答
  • 2021-01-16 14:27

    You can fire a global intent that will be picked up by the browser

    Uri uri = Uri.parse( "http://www.google.com" );
    startActivity( new Intent( Intent.ACTION_VIEW, uri ) );
    

    Also make sure to add the web permission to your manifest

    <uses-permission android:name="android.permission.INTERNET" />
    
    0 讨论(0)
  • 2021-01-16 14:35

    Just make and Intent and set the link as uri to the intent. Then use the intent to start activity. Try this:

    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com")));
    
    0 讨论(0)
提交回复
热议问题