I want to remove the dialing number from my call log. For that I have written BroadCastReceiver and inside the receiver method I have written the code like this.
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.i("sadas",phoneNumber);
}
else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
TelephonyManager.EXTRA_STATE_IDLE)) {
context.getContentResolver().delete(CallLog.Calls.CONTENT_URI, CallLog.Calls.NUMBER + " = ?", new String[] { phoneNumber });
}
else{
}
}
The above code is working with some issue. If i call the number for first time then it is removing and for second time it is not removing. Likewise for sometime it is removing.
I can't figure out the problem. Whether I did mistake at anywhere?
Please help me to solve this problem.