2014-02-12 83 views
2

如果有人有想從android中的通話記錄中刪除撥號號碼的情況,我們在撥打哪種方式的時候會在廣播接收機上撥打電話。請提前幫助我。如何從android中的通話記錄中刪除撥號號碼?

public class IncommingCallReceiver extends BroadcastReceiver { 
    @Override 
    public void onReceive(Context mContext, Intent intent) { 
     // Get the current Phone State 
     this.mContext = mContext; 
     String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); 
     callerPhoneNumber = intent.getExtras().getString("incoming_number"); 
     if (state == null) 
      return; 
     // If phone state "Rininging" 
     if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { 
      ring = true; 
      flag=0; 
      // Get the Caller's Phone Number 
     } 
     // If incoming call is received 
     if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { 
      callReceived = true; 
      flag=1; 
     } 
     // If phone is Idle 
     if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) { 
      // If phone was ringing(ring=true) and not 
      // received(callReceived=false) , then it is a missed call 
      if (ring == true && callReceived == false) { 
       flag=2; 
      } 
     } 
+0

你嘗試過這個http://stackoverflow.com/questions/16767671/delete-particular-log-from-call-log – 2014-02-12 06:54:10

回答

1

請嘗試用通話ID刪除通話記錄。使用此功能使用下面的代碼

int res = Call_logs.this.getContentResolver().delete(android.provider.CallLog.Calls.CONTENT_URI,"_ID = "+ calls_id_list.get(i),null); 
if (res == 1) 
{ 
     Uri uri = Uri.parse("content://call_log/calls"); 
     int d = getContentResolver().delete(uri, null, null);   
} 
+0

當我在呼叫撥號完成後需要調用此方法時。 – sai

+0

當然是... – user3291365

+1

請從另一個答案複製時放上真實屬性。我認爲這個答案是從這裏取的[刪除特定日誌從通話記錄](http://stackoverflow.com/questions/16767671/delete-particular-log-from-call-log) – 2014-02-12 06:56:46

1

嘗試:

public void deleteAnEntryFromCallLog(String number) 
{ 
try 
{ 
    Uri CALLLOG_URI = Uri.parse("content://call_log/calls"); 
    getApplicationContext().getContentResolver().delete(CALLLOG_URI,CallLog.Calls.NUMBER +"=?",new String[]{number}); 
} 
catch(Exception e) 
{ 
    e.printStackTrace(); 
} 
} 
+1

親愛的,你好親愛的,新的字符串[] {數字}神奇的代碼解決我的問題:) tanx很多 – Adiii

相關問題