我希望我的应用能够判断是否错过了一个电话,或者只是被解雇(当有来电时点击红色结束按钮)。
我是否使用CallLog.Calls NEW常量?
答案 0 :(得分:0)
添加:
<uses-permission android:name="android.permission.READ_CONTACTS" />
并在您的活动中添加:
Uri allCalls = Uri.parse("content://call_log/calls");
Cursor c = getContentResolver().query(allCalls, null,
CallLog.Calls.NEW + " = ?", new String[] { "1" }, null);
c.moveToFirst();
String num= c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));
String name= c.getString(c.getColumnIndex(CallLog.Calls.CACHED_NAME));
String duration = c.getString(c.getColumnIndex(CallLog.Calls.DURATION));
String type = c.getString(c.getColumnIndex(CallLog.Calls.TYPE));
Log.d("num", num);
Log.d("name", name);
Log.d("duration", duration);
Log.d("type", type);