How can I open a URL in Android's web browser from my application?

前端 未结 30 2723
庸人自扰
庸人自扰 2020-11-21 22:09

How to open an URL from code in the built-in web browser rather than within my application?

I tried this:

try {
    Intent myIntent = new Intent(Int         


        
30条回答
  •  离开以前
    2020-11-21 22:43

    Okay,I checked every answer but what app has deeplinking with same URL that user want to use?

    Today I got this case and answer is browserIntent.setPackage("browser_package_name");

    e.g. :

       Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
        browserIntent.setPackage("com.android.chrome"); // Whatever browser you are using
        startActivity(browserIntent);
    

    Thank you!

提交回复
热议问题