Android launch browser without specifying a URL

前端 未结 3 2019
误落风尘
误落风尘 2021-01-18 20:20

How would one go about launching the browser from an activity without specifying a url. I would like to open the browser so the user can continue browsing without changing t

3条回答
  •  不要未来只要你来
    2021-01-18 21:09

    this answer may help. from How to open the default android browser without specifying an URL?

    PackageManager pm = getPackageManager();
    Intent queryIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
    ActivityInfo af = queryIntent.resolveActivityInfo(pm, 0);
    Intent launchIntent = new Intent(Intent.ACTION_MAIN);
    launchIntent.setClassName(af.packageName, af.name);
    startActivity(launchIntent);
    

提交回复
热议问题