0

To make a call am using this below code.

public void onClick(View v) {
            // TODO Auto-generated method stub
            String number = "892843903";
            Intent callIntent = new Intent(Intent.ACTION_DIAL);
            callIntent.setData(Uri.parse("tel:"+number));
            ctx.startActivity(callIntent);
            deleteNumberFromCallLog(con.number);
        }

So the number is setting and ready to make call. If i call the number then number will be added to the dialed list.

But I don't want to show the dialed number in my dialed list.

Is this possible? Please give me an idea.

Sridhar
  • 668
  • 1
  • 11
  • 22

1 Answers1

0
public void deleteNumberFromCallLog(String strNum) {
    this.getContentResolver().delete(CallLog.Calls.CONTENT_URI, CallLog.Calls.NUMBER + " = ?", new String[] { strNum });
}

It requires the following permission

<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
Chandrakanth
  • 3,711
  • 2
  • 18
  • 31
  • @Sridhar Its working fine for me...can you tell what exactly you are doing(share your code) – Chandrakanth Feb 11 '15 at 07:08
  • Actually it's working fine before calling the number. I have written the calling code in button onclicklistener. I also called the method deleteNumberFromCallLog(number) by next line. So before am making call, the number setting for dial and the method also called at the same time. – Sridhar Feb 11 '15 at 07:36
  • You have to call the method after the entry has been added to the logs list. If you call the delete method immediately after calling the ctx.startActivity() it will not work. Because at that time there is not entry in the log for that number. – Chandrakanth Feb 11 '15 at 07:38
  • how can i check that whether the entry has been added to the log list? – Sridhar Feb 11 '15 at 07:41
  • To achieve the functionality you want...register a broadcast receiver with the action "android.intent.action.PHONE_STATE" and in onReceive() method of the Broadcast Receiver catch the action and when bundle.getString(TelephonyManager.EXTRA_STATE)==TelephonyManager.EXTRA_STATE_IDLE then call the deleteNumberFromCallLog(String strNum) method. – Chandrakanth Feb 11 '15 at 07:46