特定のURLに対してデフォルトのAndroidブラウザを具体的に実行したいと思います。私はこのコードを使用しています:
Intent i = new Intent();
i.setAction("android.intent.action.VIEW");
i.addCategory("android.intent.category.BROWSABLE");
i.setClassName("com.google.android.browser", "com.android.browser.BrowserActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setData(Uri.parse(url));
startActivity(i);
私が受け取るエラーは次のとおりです。
Unable to find explicit activity class {
com.google.android.browser/com.android.browser.BrowserActivity};
have you declared this activity in your AndroidManifest.xml?
また、パッケージでインテントをフィルタリングしてみました。
i.setPackage("com.google.android.browser");
の代わりにsetClassName
、しかし役に立たない:
No Activity found to handle Intent { act=android.intent.action.VIEW
cat=[android.intent.category.BROWSABLE]
dat=http://www.google.com/ flg=0x10000000 pkg=android }
<uses-library android:name="com.google.android.browser" />
マニフェストにも追加してみました。
ここで何かが足りませんか?
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")))
PS:ブラウジングのすべての選択肢が一覧表示されるので、使用することに興味はありませんIntent
。