gpt4 book ai didi

android - 如何从android的通话记录中删除拨号号码?

转载 作者:行者123 更新时间:2023-11-29 00:23:06 27 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How to remove call logs from android programmatically?

(6 个回答)


7年前关闭。




如果有人有想法从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;
}
}

最佳答案

尝试按通话 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);
}

关于android - 如何从android的通话记录中删除拨号号码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21720672/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com