问题
I have this problem only on Samsung Galaxy SIII running Android 4.1.1. There is no problem on Samsung Galaxy Ace and Samsung Galaxy Y. The broadcast SMS received is not firing up, when SMS is received. No other SMS app is installed on the phone.
I am using the following code to receive the SMS broadcast
smsReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Inside onReceive of smsReceiver");
Bundle bundle = intent.getExtras();
Object[] messages = (Object[]) bundle.get("pdus");
SmsMessage[] sms = new SmsMessage[messages.length];
// Create messages for each incoming PDU
for (int n = 0; n < messages.length; n++) {
sms[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
for (SmsMessage msg : sms) {
//do something
}
}
};
IntentFilter intentFilter = new IntentFilter();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1);
} else {
// set Interger.MAX_VALUE because other apps like Handcent are intercepting
intentFilter.setPriority(Integer.MAX_VALUE);
}
intentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
// register receiver for receive SMS
registerReceiver(smsReceiver, intentFilter);
I have set the following permission in the Manifest
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
I don't have logcat access. I have spend last two days trying to find the cause in the maze of Android but no help.
来源:https://stackoverflow.com/questions/14801658/unable-to-receive-sms-receive-broadcast-on-galaxy-siii-running-4-1-1