我在我的AndroidMainfest.xml中有两个BroadcastReceivers, 和集合<action android:name="android.intent.action.BOOT_COMPLETED" />
for bll.BootNotificationReceiver <action android:name="android.provider.Telephony.SMS_RECEIVED" />
for bll.SmsBroadcastReceiver。我需要添加ACTION.compareToIgnoreCase(intent.getAction())== 0吗?
所以我不认为我需要在public void onReceive(Context context, Intent intent)
中加ACTION.compareToIgnoreCase(intent.getAction()) == 0
对吧?
AndroidMainfest.xml
<!-- Broadcast receiver -->
<receiver android:name="bll.SmsBroadcastReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
SmsBroadcastReceiver.java
public class SmsBroadcastReceiver extends BroadcastReceiver{
private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null && intent.getAction() != null && ACTION.compareToIgnoreCase(intent.getAction()) == 0) {
PublicPar.myContext=context;
}
}
}
BootNotificationReceiver.java
public class BootNotificationReceiver extends BroadcastReceiver{
private static final String ACTION = "android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent != null && intent.getAction() != null && ACTION.compareToIgnoreCase(intent.getAction()) == 0) {
PublicPar.SetNotification();
}
}
}
我不认为我需要添加'ACTION.compareToIgnoreCase(intent.getAction())== 0'在'公共无效的onReceive(上下文语境,意图意图)',intresting .... –