Android 用于显示能够查看 URL 的活动的隐式 Intent 选择器
Android implicit Intent chooser to display Activities that are capable of viewing URLs
我正在尝试创建一个选择器意图来显示能够查看 URL 的活动。第一个 activity 应该是 Web 浏览器,第二个 activity 应该是自定义创建的 activity 我创建了调用 "MyBrowser".
当我 运行 代码时,没有活动符合我的意图。这是我调用隐式意图的方式:
Intent baseIntent = new Intent(Intent.ACTION_SEND, Uri.parse(URL));
Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
if (baseIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooserIntent);
}
这是我的自定义浏览器的 intent-filter Activity:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
我认为浏览网页应该是Intent.ACTION_VIEW
而不是Intent.ACTION_SEND
http://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW
我正在尝试创建一个选择器意图来显示能够查看 URL 的活动。第一个 activity 应该是 Web 浏览器,第二个 activity 应该是自定义创建的 activity 我创建了调用 "MyBrowser".
当我 运行 代码时,没有活动符合我的意图。这是我调用隐式意图的方式:
Intent baseIntent = new Intent(Intent.ACTION_SEND, Uri.parse(URL));
Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
if (baseIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooserIntent);
}
这是我的自定义浏览器的 intent-filter Activity:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
我认为浏览网页应该是Intent.ACTION_VIEW
而不是Intent.ACTION_SEND
http://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW