Open Chrome App with URL

后端 未结 8 1448
情话喂你
情话喂你 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:26

    Android Kotlin

    Try this below code for intent to chrome browser in kotlin.

    val uri = Uri.parse("googlechrome://navigate?url="+"https://stackoverflow.com/")
    val i = Intent(Intent.ACTION_VIEW, uri)
    if (i.resolveActivity(this@MainActivity.packageManager) == null) {
       i.data = Uri.parse("https://stackoverflow.com/")
    }
    this@MainActivity.startActivity(i)
    
    0 讨论(0)
  • 2021-02-02 15:34

    I opened my Safe Browser App with getting package name from Google play, the same way you can open for chrome by default also:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("http://Your URL"));
    intent.setPackage("com.cloudacl");  // package of SafeBrowser App 
    startActivity(intent);
    

    You can replace package com.cloudacl with this com.android.chrome to open chrome.

    0 讨论(0)
提交回复
热议问题