我正在通过短信发送 GPS 数据。我正在使用 abortBroadcast 并且在 android manifest android:priority for receiver 设置为 1000。所以当应用程序运行移动时的问题没有收到除应用程序以外的其他消息。请帮助我。
My code is as follows:
//This is Broadcast Receiver that I Registered in android manifest.
public class SimpleSmsReciever extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED"))
{
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdusObj = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdusObj.length];
for (int i = 0; i < pdusObj.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
}
for (SmsMessage currentMessage : messages) {
sender = currentMessage.getDisplayOriginatingAddress();
msg =msg+currentMessage.getDisplayMessageBody();
}
this.abortBroadcast();
//Here Iam cancelling the broadcast.
}
}