想知道如何我会去,而无需使用清单文件创建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);
上一篇:没有收到Android的GCM单向code charctersGCM、Android、charcters、code
下一篇:该方法getFragmentManager()是未定义的类型MyActivity类型、未定义、方法、MyActivity