Open Chrome App with URL

后端 未结 8 1468
情话喂你
情话喂你 2021-02-02 14:59

Is there a way to open Chrome app on Android from default Android browser? I\'m able to open the app, but it doesn\'t redirect user to correct page. This is what I tried:

<
8条回答
  •  星月不相逢
    2021-02-02 15:08

    I am using below code to open Chrome browser from Android app

    String urlString = "http://google.com";
    Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(urlString));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setPackage("com.android.chrome");
    try
    {
        context.startActivity(intent);
    } 
    catch (ActivityNotFoundException ex)
    {
        //if Chrome browser not installed
        intent.setPackage(null);
        context.startActivity(intent);
    }
    

提交回复
热议问题