我有一个侦听器来检测来电
我每次来电后都会向 CallLog 内容提供程序进行查询
即使在几秒钟前已经记录了一个呼叫,我的光标也总是返回 null
顺便说一句,我在运行项目之前清除了我的呼叫日志在日食中,
我希望能够在每次来电后将光标指向第一行,但它不起作用
// Listener to detect incoming calls.
private class CallStateListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (previousState == TelephonyManager.CALL_STATE_RINGING
&& state == TelephonyManager.CALL_STATE_IDLE) {
cursor = context.getContentResolver().query(
CallLog.Calls.CONTENT_URI, projection, null, null,
Calls.DEFAULT_SORT_ORDER);
Log.i("SIZE OF CURSOR", String.valueOf(cursor.getCount()));
if (cursor.moveToFirst()) {
}// end if
}// end if
Log.i("onCallStateChanged",
String.format("State changed to %d", state));
previousState = state;
}// end onCallStateChanged()
}// end CallStateListener class
Cursor cursor;
private String[] projection = new String[] { Calls.TYPE, Calls.NUMBER };