try something like that.
try { Intent i = new Intent(); ComponentName comp = new ComponentName("com.google.android.browser","com.google.android.browser.BrowserActivity"); i.setComponent(comp); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); ContentURI uri = new ContentURI(url); i.setData(uri); startActivityForResult(i, 2); } catch (URISyntaxException e) { e.printStackTrace(); }
for your second question you can use the PackageManager
.
get instance of PackageManager
PackageManager packageManager = getPackageManager();
and request it for specific actions, data, and Intent
categories.
Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("URL")); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : list) { if(resolveInfo.isDefault()) {
N-joy source share