我正在开发一个Android应用程序。在我的应用程序按钮中,单击应用程序自动将SMS发送到固定号码。
短信长度为127个字符,但它会向移动网络收取3条消息。
消息就像EI{{_E_3LTV{<:A<B899?8@5@>>{M5CIO?L<C>M?O=C:?{>NJ{{LWO^2Q]ST6N[[Q2YTRT6MXYX2KWQH6YTUS2`J{{A{>39393:{;66{{;8>><:97{694968796;
GL{{"G"5"VY{E8=9?;D<<@?=>B{<7F9N8FH@AQ7FI<{APM{{HUK^4NZPQ9JY_T4VQOQ9IVUV4MTNI9VOQV4_M{{=7{<:7:7:8{9{4={{:=<>>>:C{=7;7?6>7=9
**用于发送消息的代码**
TelephonyManager telMan = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMan.getSimState();
if (simState != TelephonyManager.SIM_STATE_READY) {
throw new EscanException(-13);
}
ArrayList<String> splitMsg = smsMan.divideMessage(message);
int count = splitMsg.size();
ArrayList<PendingIntent> sentIntent = new ArrayList<PendingIntent>();
for (int i = 0; i < count; i++) {
sentIntent.add(PendingIntent.getBroadcast(context, 0, new Intent(
ACTION_SENT), 0));
}
smsMan.sendMultipartTextMessage(number, null, splitMsg, sentIntent,
null);
flag = true;
context.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
handler.sendEmptyMessage(getResultCode());
if (flag) {
flag = false;
context.unregisterReceiver(this);
}
}
}, new IntentFilter(ACTION_SENT));
}
}