我正在开发一个使用短信以编程方式发送呼叫记录的应用程序。但是当我在模拟器中有两个或更多历史记录时,sendMultipartTextMessage不起作用并且短信不发送。如果有人知道如何,请帮帮我。
public void onReceive(Context context, Intent intent){
StringBuffer sb = new StringBuffer();
Cursor managedCursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, null);
int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);
int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
sb.append("Call Log :");
while (managedCursor.moveToNext()) {
String phNumber = managedCursor.getString(number);
String callType = managedCursor.getString(type); String callDate = managedCursor.getString(date);
Date callDayTime = new Date(Long.valueOf(callDate));
String callDuration = managedCursor.getString(duration);
String dir = null;
int dircode = Integer.parseInt(callType);
switch (dircode) {
case CallLog.Calls.OUTGOING_TYPE: dir = "OUTGOING";
break;
case CallLog.Calls.INCOMING_TYPE: dir = "INCOMING";
break;
case CallLog.Calls.MISSED_TYPE: dir = "MISSED";
break; }
sb.append(" :-" + phNumber );// "-" + dir +" ");
// + callDayTime + " " + callDuration);
//sb.append("\n----------------------------------");
managedCursor.close();
}
histo = sb.toString() ;
srte ="5554";
if(histo.length()>=160){
SmsManager manager = SmsManager.getDefault() ;
ArrayList<String> sms = manager.divideMessage(histo);
manager.sendMultipartTextMessage(srte, null, sms, null, null);
//Toast.makeText(context, "Message enoyer", Toast.LENGTH_LONG).show();
}
else {
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage(srte, null, histo, null, null);
// Toast.makeText(context, "Message enoyer", Toast.LENGTH_LONG).show();
}