Android intent to open user's preferred browser

后端 未结 6 774
梦如初夏
梦如初夏 2020-12-15 08:35

I\'ve been trying to find out how to create an intent that will open the user\'s preferred browser without specifying the URL. I know how to open it by giving a specific URL

6条回答
  •  北海茫月
    2020-12-15 09:09

    Use below code

    Intent sendIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.stackoverflow.com"));
    Intent chooser = Intent.createChooser(sendIntent, "Choose Your Browser");
    if (sendIntent.resolveActivity(getPackageManager()) != null) 
        startActivity(chooser);
    

提交回复
热议问题