IllegalArgumentException readExceptionFromParcel

发布于 2024-11-15 05:14:26 字数 2370 浏览 4 评论 0原文

我从我的一位用户那里收到此错误,但我不知道如何修复它...

java.lang.IllegalArgumentException DatabaseUtils.readExceptionFromParcel()

java.lang.IllegalArgumentException: URI: content://com.android.contacts/phone_lookup/, calling user: com.piroja.contactpicker, calling package:com.piroja.contactpicker at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:144)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:245)
at com.piroja.contactpicker.ContactPicker.contactExists(ContactPicker.java:257)
at com.piroja.contactpicker.ContactPicker$6$1.onClick(ContactPicker.java:138)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
at dalvik.system.NativeStart.main(Native Method)

这是我正在调用的 contactExists 函数(我认为)导致强制关闭:

public boolean contactExists(Context context, String number) {
        try {
            Uri lookupUri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri
                    .encode(number));
            String[] mPhoneNumberProjection = { Phone._ID, Phone.NUMBER,
                    Phone.DISPLAY_NAME };
            Cursor cur = context.getContentResolver().query(lookupUri,
                    mPhoneNumberProjection, null, null, null);
            try {
                if (cur.moveToFirst()) {
                    return true;
                }
            } finally {
                if (cur != null)
                    cur.close();
            }
        } catch (IllegalArgumentException iae) {
            return false;
        }
        return false;
    }

我也尝试将 Phone.CONTENT_FILTER_URI 更改为 PhoneLookup.CONTENT_FILTER_URI 但它没有改变任何内容...有人吗有线索吗?

I got this Error from one of my users and i have NO clue how to fix it...

java.lang.IllegalArgumentException
DatabaseUtils.readExceptionFromParcel()

java.lang.IllegalArgumentException: URI: content://com.android.contacts/phone_lookup/, calling user: com.piroja.contactpicker, calling package:com.piroja.contactpicker at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:144)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:245)
at com.piroja.contactpicker.ContactPicker.contactExists(ContactPicker.java:257)
at com.piroja.contactpicker.ContactPicker$6$1.onClick(ContactPicker.java:138)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
at dalvik.system.NativeStart.main(Native Method)

This is the contactExists funcion i'm calling which (i think) is causing the force close:

public boolean contactExists(Context context, String number) {
        try {
            Uri lookupUri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri
                    .encode(number));
            String[] mPhoneNumberProjection = { Phone._ID, Phone.NUMBER,
                    Phone.DISPLAY_NAME };
            Cursor cur = context.getContentResolver().query(lookupUri,
                    mPhoneNumberProjection, null, null, null);
            try {
                if (cur.moveToFirst()) {
                    return true;
                }
            } finally {
                if (cur != null)
                    cur.close();
            }
        } catch (IllegalArgumentException iae) {
            return false;
        }
        return false;
    }

I have also tried to change Phone.CONTENT_FILTER_URI to PhoneLookup.CONTENT_FILTER_URI but it didn't change anything... Does anyone have a clue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

装迷糊 2024-11-22 05:14:26

电话查询 URI 有问题。从异常文本来看,它似乎缺少电话号码。您确定数字不为空且不为空吗?

There is something wrong with the phone query URI. From the exception text it looks like it is missing the phone number. Are you sure number is not null and not empty?

并安 2024-11-22 05:14:26

屏蔽号码可能会发生这种情况。
http://code.google.com/p/gtalksms/issues/detail ?id=27

旧人哭 2024-11-22 05:14:26

我不知道是否有人还需要这个答案,但我一直在努力,直到得到它。问题是,有时,当您扩展 PhoneStateListener 类或传递最后一个传入号码时,传入号码为 null。我将代码更改为这个,并且工作正常

@Override
public void onReceive(final Context context, final Intent intent) {
    Log.d("APP", "ACTION:" + intent.getAction());
    final String stringExtra = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(stringExtra)) {
            final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.d("APP", "incoming,ringing:" + incomingNumber);
        } else if (stringExtra.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
            final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.d("APP", "hanged" + incomingNumber );
        } else if (stringExtra.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
            final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.d("APP", "answered" + incomingNumber );
        }
    }

......这个解决方案是 此处

I don't know if anyone still needs this answer, but I tried until I got it. The problem is that sometimes, the incoming number is null when you either extend PhoneStateListener class, or when passing the last incoming number. I changed my code to this, and it worked fine

@Override
public void onReceive(final Context context, final Intent intent) {
    Log.d("APP", "ACTION:" + intent.getAction());
    final String stringExtra = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(stringExtra)) {
            final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.d("APP", "incoming,ringing:" + incomingNumber);
        } else if (stringExtra.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
            final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.d("APP", "hanged" + incomingNumber );
        } else if (stringExtra.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
            final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.d("APP", "answered" + incomingNumber );
        }
    }

… this solution is here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文