try something like this.
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 PackageManager
.
get instance of PackageManager
PackageManager packageManager = getPackageManager();
and query it for specific action, data and category of Intent
.
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())
{
//default browser
}
}
resolveInfo.isDefault
is ever true for any browser! Please help. – Transformism