短信广播接收机无舱单 [英] SMS Broadcast Receiver without Manifest
问题描述
想知道如何我会去,而无需使用清单文件创建SMS广播接收机。因此,举例来说,这是我目前的清单文件行:
Wondering how I would go about creating an SMS Broadcast Receiver without using the Manifest file. So for instance, this is my current manifest file line:
<receiver android:name="com.paradopolis.randomnotifications.SMSListener">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
和它的工作很好,但我希望能够删除行,我的服务像内登记自己的广播接收器:
and it's working fine, but I'd like to be able to remove the line and register my broadcast receiver within my service like:
registerReceiver(new SMSListener() , [?????]);
但我找不到意图过滤器来使用,因为SMS_RECEIVED是电话软件包的一部分。所以,问题是:什么是意图过滤器
but I can not find the Intent filter to use, since SMS_RECEIVED is part of the Telephony package. So the question is: What is that intent filter?
推荐答案
在你的java文件,然后 registerReceiver(接收器,IntentFilter的)
Create IntentFilter
in your java file, then registerReceiver(Receiver, IntentFilter)
该行动将是 android.provider.Telephony.SMS_RECEIVED
为字符串。
IntentFilter i = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(new SMSListener() , i);
这篇关于短信广播接收机无舱单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!