添加意图过滤器以在SMS事件上收听ACTION_VIEW

时间:2015-02-20 11:55:16

标签: android android-intent sms android-manifest intentfilter

我正在编写一个短信应用,它会根据Google blog收听Kitkat上方短信应用所需的所有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应用程序显示在“操作选择器”对话框中,但不显示在我的应用程序中。要添加到清单中以便将我的应用程序列出到此的方案是什么。 这是包含意图过滤器的Manifest部分。

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

1 个答案:

答案 0 :(得分:2)

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

清单设计----&gt;

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

相关问题