问题是:我定义一个广播,接收发送来的短信。但是,当我退出我的应用时,我的代码不能接收短信哦,怎么样才能让程序可以接收信息哦?代码如下:.MyStartB是我自定义的广播 <receiver android:name=".MyStartB" >
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>广播MyStartBpublic class MyStartB extends BroadcastReceiver {
static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";@Override
public void onReceive(Context context, Intent intent) {
Log.e("TAG", "*****onReceive01******************");
if (intent.getAction().equals(MyStartB.ACTION)) {
Log.e("TAG", "*****onReceive02******************");}}//运行之后,没有输出结果哦,请大家帮我看看,怎么为事哦。可能是我没有发送广播。//我要发送广播得在activity里,但是我退出程序之后,activity也退出了,那么就不能//接收广播了吗?怎么样,让程序可以接收信息广播
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>广播MyStartBpublic class MyStartB extends BroadcastReceiver {
static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";@Override
public void onReceive(Context context, Intent intent) {
Log.e("TAG", "*****onReceive01******************");
if (intent.getAction().equals(MyStartB.ACTION)) {
Log.e("TAG", "*****onReceive02******************");}}//运行之后,没有输出结果哦,请大家帮我看看,怎么为事哦。可能是我没有发送广播。//我要发送广播得在activity里,但是我退出程序之后,activity也退出了,那么就不能//接收广播了吗?怎么样,让程序可以接收信息广播
<receiver android:name=".MyStartB" android:enabled="true" >
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>一样,运行没有反应哦,log不输出哦···