小五六资源网,小五六博客

Android 修改手机通讯录

发布:小五六资源网 2019年11月8日 9:46 星期五分类: Android

 
String  [] phoneItem = new String[]{"12599802004","95280371","01053902263","12599802004","95280360","125909818006","01053902251","125909818003","125909818004","125909818007","95280361","95280367","95701419","125909888323","95280365","95280323","95280310","95280395","95280335","051568034003","051568034001","051568034021","0515680340123","05156803400300","05156803400385","05156803400346","05156803400388","05156803400355"};

insertCallLog(phoneItem[1],"0","3","0");
权限:
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />


/*
* 插入一条通话记录 * @param number 通话号码 * @param duration 通话时长(响铃时长)以秒为单位 1分30秒则输入90 * @param type 通话类型 1呼入 2呼出 3未接 * @param isNew 是否已查看 0已看1未看 */ private void insertCallLog(String number, String duration, String type, String isNew) { ContentValues values = new ContentValues(); values.put(CallLog.Calls.NUMBER, number); values.put(CallLog.Calls.DATE, System.currentTimeMillis() ); values.put(CallLog.Calls.DURATION, duration); values.put(CallLog.Calls.TYPE, type); values.put(CallLog.Calls.NEW, isNew); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_CALL_LOG}, 1000); } getContentResolver().insert(CallLog.Calls.CONTENT_URI, values); }
温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,谢谢合作!

发表评论: