How to find default browser set on android device

前端 未结 2 675
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 05:07

Is there any way to find out which browser is set as a default browser on android device? On android device there may be multiple browsers installed but out of which only on

相关标签:
2条回答
  • 2020-12-03 05:55

    You are welcome to use PackageManager and resolveActivity() to attempt to determine what activity (in what app) will handle a particular Intent. However, this may indicate that the chooser will handle the request, because there is no current default (e.g., user just installed a new browser, and so the chooser will appear for the next Web browser request).

    0 讨论(0)
  • 2020-12-03 05:59

    This code may help you:

    Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://"));  
    ResolveInfo resolveInfo = getPackageManager().resolveActivity(browserIntent,PackageManager.MATCH_DEFAULT_ONLY);
    
    // This is the default browser's packageName
    String packageName = resolveInfo.activityInfo.packageName;
    

    and if wanna start it, do as follows:

    startActivity(getPackageManager().getLaunchIntentForPackage(packageName));
    
    0 讨论(0)
提交回复
热议问题