1

使用下面的代码,我可以删除来​​自特定号码的呼叫,这很好,只是速度很慢,并且在代码运行时应用程序变得无响应(特别是如果日志中有很多呼叫)

所以我真正想要的是它只检查日志中的最后一个调用,而不是通过漏洞日志。

String strUriCalls = "content://call_log/calls";
    Uri UriCalls = Uri.parse(strUriCalls);
    Cursor c = context.getContentResolver().query(UriCalls, null, null,
            null, null);
    if (c.getCount() <= 0) {
        Toast.makeText(context, "Call log empty", Toast.LENGTH_SHORT)
                .show();
    }

    while (c.moveToNext()) {
        SharedPreferences sp = PreferenceManager
                .getDefaultSharedPreferences(context);
        String gonnabprefd = sp.getString("callerase", null);
        String[] numarry = gonnabprefd.split(" ");
        for (int i = 0; i < numarry.length; i++) {
            String gonnabpref = numarry[i];
            String queryString = "NUMBER='" + gonnabpref + "'";
            Log.v("Numberimcomingreciver ", queryString);
            int b = context.getContentResolver().delete(UriCalls,
                    queryString, null);
            if (b >= 1) {
                Toast.makeText(context, "deleted", Toast.LENGTH_LONG)
                        .show();}}
4

1 回答 1

0

讨厌回答我自己的问题,但删除

while (c.moveToNext()) {

工作过

于 2012-05-16T18:59:31.287 回答