Android intent to open user's preferred browser

后端 未结 6 778
梦如初夏
梦如初夏 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 08:47

                Uri uri = Uri.parse("www.google.com");
                Intent intent = new Intent(Intent.ACTION_VIEW,uri);
                // Create and start the chooser
                Intent chooser = Intent.createChooser(intent, "Open with");
                startActivity(chooser);
    

    This code creates an intent to open user specified browser.

提交回复
热议问题