1
我怎樣才能找出最後進入的「數量」是叫我嗎?(接電話)如何獲得最後的「收到」電話號碼?
請不要回答以下鱈魚 他有一個錯誤(因爲該類擴展PhoneStateListener
和方法需要Activity
爲延伸:?
public class CallStat extends PhoneStateListener {
String LOG_TAG = "calllog";
private boolean isPhoneCalling = false;
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (TelephonyManager.CALL_STATE_RINGING == state) {
// phone ringing
Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
}
if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
// active
Log.i(LOG_TAG, "OFFHOOK");
isPhoneCalling = true;
}
if (TelephonyManager.CALL_STATE_IDLE == state) {
// run when class initial and phone call ended, need detect flag
// from CALL_STATE_OFFHOOK
Log.i(LOG_TAG, "IDLE number");
if (isPhoneCalling) {
Handler handler = new Handler();
//Put in delay because call log is not updated immediately when state changed
// The dialler takes a little bit of time to write to it 500ms seems to be enough
handler.postDelayed(new Runnable() {
@Override
public void run() {
// get start of cursor
Log.i("CallLogDetailsActivity", "Getting Log activity...");
String[] projection = new String[]{Calls.NUMBER};
Cursor cur = getContentResolver().query(Calls.CONTENT_URI, projection, null, null, Calls.DATE +" desc");
cur.moveToFirst();
String lastCallnumber = cur.getString(0);
}
},500);
isPhoneCalling = false;
}
}
}
}
我知道傳出但對於傳入
我需要一種用於「進入」調用 – AlizerA
上面的代碼是用於返回來電分貝內容。你甚至看到我的答案?! –
Cursor cur = getContentResolver()。query(android.provider.CallLog.Calls.INCOMING_TYPE,projection,null,null,Calls.DATE +「desc」); //語法錯誤 – AlizerA