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

标签 android android-intent sms android-manifest intentfilter

我正在编写一个 SMS 应用程序,它根据 Google blog 监听 Kitkat 之上的 SMS 应用程序所需的所有 AndroidManifest 更改。 。 我也尝试过与短信相关的 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 中以列出我的应用程序的方案是什么。 这是我的 list 部分,其中包含 Intent 过滤器。

<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/

相关文章:

android - 在相机和图库之间进行选择以进行图像选择

java - 日历 String.valueOf()

java - android SmsManager 显示消息是否发送给已关闭的号码?

Android 将多个号码传递给 SMS Intent

Android SmsProvider,ICC代表什么?

php - 如何将我的 Android 应用程序连接到我的 PHP/MySQL 后端?

java - 如何在我的编码 android studio 项目中实现此代码 setDisplayName?

Android,如何在ListView中获取一行中的单个项目?

android - 如何在左右侧 View 上创建阴影?

android - 使用 fragment 处理 setDisplayHomeAsUpEnabled