Get android system browser launch intent

About XMTV Player Forums Development Get android system browser launch intent

This topic contains 0 replies, has 1 voice, and was last updated by  support 2 years ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #436

    support
    Keymaster

    How to start system browser with specific url, instead of default Android chooser dialog if you have more then one installed browser. This is useful, when you must be sure that user will see some web page with default installed system browser.

    
    Uri mUri = Uri.parse(url);
    final Intent mIntent = new Intent(Intent.ACTION_VIEW, mUri);
    final List<ResolveInfo> appList = context.getPackageManager().queryIntentActivities(mIntent, PackageManager.PERMISSION_GRANTED);
    if (appList.size() > 0) {
    	String mPackageName = GetSysLaunchIntent(appList);
    	Intent mIntentLaunch = context.getPackageManager().getLaunchIntentForPackage(mPackageName);
    	IntentLaunch.setAction(Intent.ACTION_VIEW);
    	IntentLaunch.setData(mUri);
    	startActivity(mIntentLaunch);
    }
    
    private String GetSysLaunchIntent(List<ResolveInfo> list) {
    	for (ResolveInfo resolveInfo : list) {
    		ApplicationInfo ai;
    		try {
    			ai = context.getPackageManager().getApplicationInfo(resolveInfo.activityInfo.packageName, 0);
    			if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
    				return resolveInfo.activityInfo.packageName;
    			}
    		} catch (NameNotFoundException e) {
    			e.printStackTrace();
    		}
    	}
    	return null;
    }
    
    • This topic was modified 2 years ago by  support.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

IPTV | Smart TV | Mobile Theatre Software | Media Player for Android(tm)