短信的处理移到线程中

hdrplus
Matthew 12 months ago
parent 26eb4f46b7
commit 6ca4d14afd

@ -3,6 +3,7 @@ package com.xypower.mpmaster.sms;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils;
import com.dev.devapi.api.SysApi; import com.dev.devapi.api.SysApi;
@ -15,9 +16,29 @@ import com.dev.devapi.api.SysApi;
public class SmsSendReceiver extends BroadcastReceiver { public class SmsSendReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); final String action = intent.getAction();
if (SimUtil.SMS_SEND_ACTION.equals(action)) { if (SimUtil.SMS_SEND_ACTION.equals(action)) {
String type = intent.getStringExtra(SimUtil.SMSTYPE); final String type = intent.getStringExtra(SimUtil.SMSTYPE);
if (TextUtils.isEmpty(type)) {
return;
}
Thread th = new Thread(new Runnable() {
@Override
public void run() {
try {
processSms(context, intent, action, type);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
th.start();
}
}
public void processSms(final Context context, Intent intent, final String action, final String type) {
if (type.contains(SmsTypeEnum.REBOOT1.value())) { if (type.contains(SmsTypeEnum.REBOOT1.value())) {
SysApi.reboot(context); SysApi.reboot(context);
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) { } else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
@ -47,4 +68,3 @@ public class SmsSendReceiver extends BroadcastReceiver {
} }
} }
} }
}
Loading…
Cancel
Save