android - 如何对浏览器的 Intent 使用react?

标签 android

你们好。

你知道你什么时候从浏览器做选项/更多/分享页面吗?好吧,我希望我的 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/

相关文章:

android - 广播接收器 IntentReceiverLeaked

java - ListView 中的搜索栏 JSON 解析数据错误 NullPointerException

Android如何获取一个联系人用户的多个电子邮件地址?

android - java.lang.ClassCastException : com. eng.bt_eng_mobility.viewmodel.HomeViewModelFactory 无法转换为 androidx.lifecycle.ViewModel

android table layout 一个用于两者(横向和纵向 View )

java - 端口转发在 android 模拟器中不起作用

android - 如何使用 Room 访问 CalendarProvider?

android - 移动设备上的 Twitter Bootstrap 模式

android - 从安卓浏览器获取url

android - 新的 NDK 插件有什么作用?