gpt4 book ai didi

android - 添加 Intent 过滤器以监听 SMS 事件上的 ACTION_VIEW

转载 作者:行者123 更新时间:2023-11-29 00:13:18 25 4
gpt4 key购买 nike

我正在编写一个 SMS 应用程序,它根据 Google blog 监听 Kitkat 以上的 SMS 应用程序所需的所有 AndroidManifest 更改。 .我也在尝试与 SMS 相关的 ACTION_VIEW 请求。这种格式的东西。

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("content://mms-sms/conversations/" + msg.thread_id));
mContext.startActivity(intent);

这是为此次通话显示的屏幕。

Action chooser dialog

对于此调用,其他 SMS 应用程序显示在“操作选择器”对话框中,但我的应用程序不显示。要将我的应用程序添加到 list 中的方案是什么。这是我的包含 intent 过滤器的 list 部分。

<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>

最佳答案

您只需在 Manifest.xml 文件中添加 android:exported 属性。 android:exported="true" 属性将使您的 Activity 在您的应用程序边界之外可见,以便其他应用程序可以调用您的 Activity 来解决类似的 Intent 。将您提到的所有属性添加到您的 Activity 中,如下所示,您的应用程序也将出现在 Intent 解析屏幕中。 list 代码在下面。我还附上了我的答案的屏幕截图。

list 设计---->

<activity android:name=".activities.Experimental"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>

</activity>

Here is the screenshot where my app Hoster appear as a choice.

关于android - 添加 Intent 过滤器以监听 SMS 事件上的 ACTION_VIEW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28628402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com