当前位置:  编程技术>移动开发
本页文章导读:
    ▪[拾掇] 操作通话记录(二)        [整理] 操作通话记录(二)   //处理时间   public  String formatDuring(long mss) {         long hours = mss / (60 * 60);         long minutes = (mss % (1000 * 60 * 60)) / 60;         long seconds = (mss % (1000 .........
    ▪ [拾掇] 操作通话记录(一)        [整理] 操作通话记录(一)   /* *为了方便后面页面的封装,这里定义了一个实体类 */ public class Call {     private Bitmap img;     private String telName;     private String telNo;     private String telDate;.........
    ▪ "Copy" did not complete normally. Please see the log for more information       "Copy" did not complete normally. Please see the log for more information. "Copy" did not complete normally. Please see the log for more information.   这个错误是由于你开着有道词典的问题,把词典的划词翻译关了就好了 .........

[1][拾掇] 操作通话记录(二)
    来源: 互联网  发布时间: 2014-02-18
[整理] 操作通话记录(二)

 

//处理时间

  public  String formatDuring(long mss) {
         long hours = mss / (60 * 60);
         long minutes = (mss % (1000 * 60 * 60)) / 60;
         long seconds = (mss % (1000 * 60));
         return hours + ":" + minutes+ ":" + seconds;
     }


 public String getdays(long callTime) {
  String value = "";
  long newTime = new Date().getTime();
  long duration = (newTime - callTime) / (1000 * 60);
  if (duration < 60) {
   value = duration + "分钟前";
  } else if (duration >= 60 && duration < DAY) {
   value = (duration / 60) + "小时前";
  } else if (duration >= DAY && duration < DAY * 2) {
   value = "昨天";
  } else if (duration >= DAY * 2 && duration < DAY * 3) {
   value = "前天";
  } else if (duration >= DAY * 7) {
   SimpleDateFormat sdf = new SimpleDateFormat("M月dd日");
   value = sdf.format(new Date(callTime));
  } else {
   value = (duration / DAY) + "天前";
  }
  return value;
 }


    
[2] [拾掇] 操作通话记录(一)
    来源: 互联网  发布时间: 2014-02-18
[整理] 操作通话记录(一)

 

/*

*为了方便后面页面的封装,这里定义了一个实体类

*/

public class Call {

    private Bitmap img;

    private String telName;

    private String telNo;

    private String telDate;

    private String telTime;

    private String simpleTime;

    private int type;

    private String longTime;

 

get、set......

}

 

/*

*获取所有的通话记录

*/

public List<Call> getCallList() {

        List<Call> list = new ArrayList<Call>();

        int type;

        Date date; //日期

        String time = "";//通话时间

        String telName = "";//姓名

        String telNo = "";//电话号码

 

        ContentResolver cr = getContentResolver();

        final Cursor cursor = cr.query(CallLog.Calls.CONTENT_URI, new String[] {

                CallLog.Calls.NUMBER, CallLog.Calls.CACHED_NAME,

                CallLog.Calls.TYPE, CallLog.Calls.DATE,CallLog.Calls.DURATION }, null, null,

                CallLog.Calls.DEFAULT_SORT_ORDER);

        for (int i = 0; i < cursor.getCount(); i++) {

            Call call = new Call();

            cursor.moveToPosition(i);

            telName = cursor.getString(1);

            telNo = cursor.getString(0);

            type = cursor.getInt(2);

            SimpleDateFormat sfd = new SimpleDateFormat("HH:mm:ss");

            SimpleDateFormat sfd2 = new SimpleDateFormat("yyyy-MM-dd");

            date = new Date(Long.parseLong(cursor.getString(3)));

            time = sfd.format(date);

            call.setLongTime(formatDuring(Long.valueOf(cursor.getString(4)));

           

            String callDate = getdays(Long.parseLong(cursor.getString(3)));

            String x = getContactIDFromPhoneNum(telNo);

            byte[] kk = getPhoto(x);//联系人头像

            if (kk != null) {

                img = BitmapFactory.decodeByteArray(kk, 0, kk.length);

                call.setImg(img);

            }

            Manager.addList(img, telName, telNo, callDate, time,

                    sfd2.format(date), type);

            call.setTelName(telName);

            call.setTelNo(telNo);

            call.setType(type);

            call.setTelDate(callDate);

            call.setTelTime(time);

            if (CallLog.Calls.INCOMING_TYPE == type) {//已接来电

                call.setType(0);

            } else if (CallLog.Calls.OUTGOING_TYPE == type) {//已拨

                call.setType(1);

            } else if (CallLog.Calls.MISSED_TYPE == type) {//未接来电

                call.setType(-1);

            }  

            list.add(call);

        }

return list;

    }

 

/*

*删除记录

*/

    public void deleteLog(String phoneNumber){

           String strUriInbox = "content://call_log/calls";  

           Uri uriCall = Uri.parse(strUriInbox);  

         Cursor c = getContentResolver().query(uriCall,  

                    new String[] { "_id", "number", "date" }, null, null, null); 

            if (c != null && c.moveToFirst()) {  

                    String num = c.getString(1);  

                    String id = c.getString(0);  

                    if (num != null &&phoneNumber!=null&& num.equals(phoneNumber)) {  

                        getContentResolver().delete(uriCall, "_id=" + id, null);  

                    }  

                c.close();   }

}

 

 

 

以下代码源自互联网,由于众多网络转载的原因,未找到原作者,请原作者见谅

 

/*

*获取联系人头像

*/

public byte[] getPhoto(String people_id) {

        Cursor cur1 = null;

        String photo_id = null;

        String[] projection1 = new String[] {

        ContactsContract.Contacts.PHOTO_ID

        };

        if (people_id != null && !"".equals(people_id)) {

            String selection1 = ContactsContract.Contacts._ID + " = "

                    + people_id;

            try {

                cur1 = getContentResolver().query(

                        ContactsContract.Contacts.CONTENT_URI, projection1,

                        selection1, null, null);

            } catch (Exception e) {

            }

            if (cur1.getCount() > 0) {

                cur1.moveToFirst();

                photo_id = cur1.getString(0);

            }

            String[] projection = new String[] {

            ContactsContract.Data.DATA15

            };

            String selection = "ContactsContract.Data._ID = " + photo_id;

            Cursor cur = getContentResolver().query(

                    ContactsContract.Data.CONTENT_URI, projection, selection,

                    null, null);

            cur.moveToFirst();

            if (cur.getCount() < 0 || cur.getCount() == 0) {

                return null;

            }

            byte[] contactIcon = cur.getBlob(0);

            if (contactIcon == null) {

                return null;

            } else {

                return contactIcon;

            }

        } else {

            return null;

        }

    }

 


    
[3] "Copy" did not complete normally. Please see the log for more information
    来源: 互联网  发布时间: 2014-02-18
"Copy" did not complete normally. Please see the log for more information.

"Copy" did not complete normally. Please see the log for more information.

 

这个错误是由于你开着有道词典的问题,把词典的划词翻译关了就好了

1 楼 黑洞风 2011-12-02  
果然,楼主英明啊,哈哈,谢谢

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3