我有一个听众低于检测来电
我做一个查询到CallLog内容提供商每次后来电
我的光标总是返回null即使已经有通话记录的几秒钟前
顺便说一句,我清除我的通话记录运行
我希望能够来电后,在第一行的每个指向我的光标在Eclipse项目之前,但它只是不工作
为什么我的游标返回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 };
用户收到的任何来电。无论您是接听电话还是错过了通话,它都会在来电后向CallLog内容提供商进行查询 – Marss