What is the intent to launch any website link in Google Chrome

后端 未结 6 496
不思量自难忘°
不思量自难忘° 2020-12-09 13:20

Hi I want to open the website in chrome app from my app webview when user click on particular link. I see this is possible https://developer.chrome.com/multidevice/android/i

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 14:24

    I have tested below code with Nexus 6 with Chrome and Mozilaa installed and it works great,

        String url = "http://www.stackoverflow.com";
        Intent i = new Intent();
        i.setPackage("com.android.chrome");
        i.setAction(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
    

    This will give error if Chrome is not installed in your device. So put check for package availability.

提交回复
热议问题