你们好。
你知道你什么时候从浏览器做选项/更多/分享页面吗?好吧,我希望我的 Activity 显示在所有能够响应该浏览器 Intent 的应用程序的菜单中。事情是我不知道如何在 list 中编写 Intent 过滤器。另外,我如何访问页面的 URL 和标题等数据,这些数据应该作为额外内容添加到 Intent 中?
干杯
最佳答案
目前我无法对此进行测试以确保确定,但我认为您可以使用下面的代码注册为 SEND Intent 过滤器,然后您应该显示为提供者。
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
然后从extras中获取文本..
Intent callingIntent = getIntent();
String url = callingIntent.getStringExtra(Intent.EXTRA_TEXT);
我还建议查看 documentation for ACTION_SEND查看支持的 mime 类型和额外的键值对。
来自 ACTION_SEND 文档:
Input: getType() is the MIME type of the data being sent. get*Extra can have either a EXTRA_TEXT or EXTRA_STREAM field, containing the data to be sent. If using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it should be the MIME type of the data in EXTRA_STREAM. Use / if the MIME type is unknown (this will only allow senders that can handle generic data streams).
Optional standard extras, which may be interpreted by some recipients as appropriate, are: EXTRA_EMAIL, EXTRA_CC, EXTRA_BCC, EXTRA_SUBJECT.
关于android - 如何对浏览器的 Intent 使用react?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3250119/