我有一個聽衆低於檢測來電
我做一個查詢到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