码:
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_call_log);tv = (TextVIEw) findVIEwByID(R.ID.call); getCallDetails();}private voID getCallDetails() { // Todo auto-generated method stub StringBuffer sb = new StringBuffer(); Cursor managedCursor = managedquery( CallLog.Calls.CONTENT_URI,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 Details :"); 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( "\nPhone Number:--- "+phNumber +" \nCall Type:--- "+dir+" \nCall Date:--- "+callDayTime+" \nCall duration in sec :--- "+callDuration ); sb.append("\n----------------------------------"); } managedCursor.close(); String str = sb.toString(); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage("5554",str,null); }解决方法 因为您的消息字符串长度可能超过一个消息长度,因此如果字符串超出SMS大小限制,则使用 smsManager. divideMessage (String text)发送消息:
SmsManager sms = SmsManager.getDefault(); if(str.length()>160){ ArrayList<String> smses = smsManager.divIDeMessage(str); smsManager.sendMultipartTextMessage("5554",smses,null); }else{ sms.sendTextMessage("5554",null); }
并确保您在AndroIDManifest.xml中添加了以下权限:
<uses-permission androID:name="androID.permission.SEND_SMS" />总结
以上是内存溢出为你收集整理的如何通过Android中的短信发送呼叫记录历史记录?全部内容,希望文章能够帮你解决如何通过Android中的短信发送呼叫记录历史记录?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)