Android 安卓专用端口数据短信监听不稳定
我有一个从电信接收数据短信的应用程序。在我的代码中,我在活动中注册了动态广播接收器。它的工作很好,但有时我丢失了一些短信,我不知道为什么。这是我的密码Android 安卓专用端口数据短信监听不稳定,android,broadcastreceiver,Android,Broadcastreceiver,我有一个从电信接收数据短信的应用程序。在我的代码中,我在活动中注册了动态广播接收器。它的工作很好,但有时我丢失了一些短信,我不知道为什么。这是我的密码 IntentFilter mFilter = new IntentFilter( "android.intent.action.DATA_SMS_RECEIVED"); mFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mFilter.addDataAuthori
IntentFilter mFilter = new IntentFilter(
"android.intent.action.DATA_SMS_RECEIVED");
mFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
mFilter.addDataAuthority("localhost", "my port");
mFilter.addDataScheme("sms");
if (smsReceiver == null)
smsReceiver = new SmsReceiverBroadcast();
context.registerReceiver(smsReceiver, intentFilter);
注册广播到活动后,我等待60秒
long time = 0;
int delay = 200;
while (!Variable.getMessage && !finish
&& !Util.isTimeout(time, Timer)) {
Util.sleep(delay);
time += delay;
}
和我的广播接收器:
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null && bundle.containsKey("pdus")) {
Object[] pdus = (Object[]) bundle.get("pdus");
if (pdus != null) {
String pduString = toHexString((byte[]) pdus[0]);
LogParams.pdu = (byte[]) pdus[0];
msgs = new SmsMessage[pdus.length];
for (int i = 0; i < msgs.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
if (msgs[i].getMessageBody() != null) {
str += msgs[i].getMessageBody().toString();
Variable.isReadPdu = true;
} else {
PduParser pduparser = new PduParser();
Pdu pdu = pduparser.parsePdu(pduString);
str += pdu.getDecodedText();
Variable.isReadPdu = true;
}
Bundle=intent.getExtras();
SmsMessage[]msgs=null;
字符串str=“”;
if(bundle!=null&&bundle.containsKey(“PDU”)){
Object[]pdus=(Object[])bundle.get(“pdus”);
如果(PDU!=null){
字符串pduString=tohextstring((字节[])pdus[0]);
LogParams.pdu=(字节[])pdu[0];
msgs=新SMS消息[PDU.length];
对于(int i=0;i
我的代码有什么问题?定义“丢失几条短信”?(你可能想在清单中注册你的BR以接收所有短信)我的意思是我每1000条短信丢失大约100条。哦,绝对不,我不需要清单中的resister BR,因为我在活动中注册了动态。定义“丢失”。你怎么知道它们是“丢失”的?是的,我有一个从电信发送数据消息到Android客户端的系统,它成功地发送了数据消息,但有时Android客户端没有收到。它不稳定。而且,股票Android消息应用程序收到了吗?