获取未接来电列表,并从通话记录中的android删除 [英] Get the missed call list and delete it from call log in android
问题描述
我想要得到的特定的呼叫类型独自从通话记录在Android中删除。
I want to get the particular call type alone and delete it from the call log in android.
while (cursor.moveToNext()) {
String queryString1= "CallType=’" + CallLog.Calls.MISSED_TYPE + "‘";
Log.v("CallType", queryString1);
if(CallLog.Calls.TYPE.equals("missed")) {
sb.append("Number "+CallLog.Calls.NUMBER+"\nName "+CallLog.Calls.CACHED_NAME);
}
}
getContentResolver().delete(UriCalls, CallLog.Calls.MISSED_TYPE, null);
这是一个codeI已经尝试了未接来电,因为Missed_type为int,我得到一个错误的方法删除(URI,字符串,字符串[])在类型ContentResolver的不适用的参数(乌里,INT,空)
This is a code i ve tried for missed call,because of Missed_type is int, i got an error "The method delete(Uri, String, String[]) in the type ContentResolver is not applicable for the arguments (Uri, int, null)"
给我一些建议删除日志中特定的呼叫类型
Give me some tips to delete the particular call type from log
推荐答案
您可以使用下面的code,以获取未接来电警告
you can use following code to fetch Missed call Alert
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = android.provider.CallLog.Calls.DATE + " DESC";
Cursor cursor = null;
try{
cursor = context.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
while (cursor.moveToNext()) {
String callLogID = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls._ID));
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
String callDate = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.DATE));
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
String isCallNew = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NEW));
if(Integer.parseInt(callType) == MISSED_CALL_TYPE && Integer.parseInt(isCallNew) > 0){
if (_debug) Log.v("Missed Call Found: " + callNumber);
}
}
} catch(Exception ex){
if (_debug) Log.e("ERROR: " + ex.toString());
}finally{
cursor.close();
}
您也可以使用此链接的http://android2011dev.blogspot.in/2011/08/get-android-phone-call-historylog.html
<使用-权限的Android:名称=android.permission.READ_LOGS>< /使用-许可>
给上述许可的 AndroidManifest.xml中
使用下面的链接删除未接来电列表,你只需要传递,美从上面code
use following link to delete missed call list , you just need to pass number that u got from above code
http://www.mobisoftinfotech.com/blog/android/androidcalllogdeletion/
这篇关于获取未接来电列表,并从通话记录中的android删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!