本文介绍了彩信内容提供商发行(三星Galaxy S3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们碰到下面的崩溃,当我们尝试查询的内容://彩信,短信/通话/在三星Galaxy S3(安卓4.0.4)Sprint的网络上运行。我们调用code:

 开放的URI = Uri.parse(内容://彩信,短信/通话/);

    Log.e(IL,内容的MIME+ context.getApplicationContext()getContentResolver()的getType(URI)。);

    //下面的调用崩溃...
     光标光标= context.getApplicationContext()getContentResolver()查询(URI,NULL,NULL,NULL,NULL);
 

有趣的事实是,上述收益日志

 内容MIME vnd.android-DI​​R / MMS短信
 

如预期。

下面

堆栈跟踪:

 产生的原因:显示java.lang.NullPointerException
在android.os.Parcel.readException(Parcel.java:1333)
在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:182)
在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136)
在android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
在android.content.ContentProviderClient.query(ContentProviderClient.java:50)
在com.ilyngo.sms.model.MessageCatalog.refresh(MessageCatalog.java:107)
在com.ilyngo.sms.model.MessageCatalog.getSharedCatalog(MessageCatalog.java:58)
在com.ilyngo.sms.model.ContactsManager.clearCaches(ContactsManager.java:31)
在com.ilyngo.sms.app.bill_test.ThreadListActivity.onResume(ThreadListActivity.java:57)
在android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
在android.app.Activity.performResume(Activity.java:4544)
在android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
... 12更多
显示java.lang.NullPointerException
在android.os.Parcel.readException(Parcel.java:1333)
在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:182)
在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136)
在android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
在android.content.ContentProviderClient.query(ContentProviderClient.java:50)
在com.ilyngo.sms.model.MessageCatalog.refresh(MessageCatalog.java:107)
在com.ilyngo.sms.model.MessageCatalog.getSharedCatalog(MessageCatalog.java:58)
在com.ilyngo.sms.model.ContactsManager.clearCaches(ContactsManager.java:31)
在com.ilyngo.sms.app.bill_test.ThreadListActivity.onResume(ThreadListActivity.java:57)
在android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
在android.app.Activity.performResume(Activity.java:4544)
在android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
在android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2486)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2000)
在android.app.ActivityThread.access $ 600(ActivityThread.java:128)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1161)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:137)
在android.app.ActivityThread.main(ActivityThread.java:4514)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:980)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
在dalvik.system.NativeStart.main(本机方法)
 

解决方案

问题可以通过查询简化版本来解决:

  Uri.parse(内容://彩信,短信/通话简单=真正的);
光标光标= context.getApplicationContext()getContentResolver()查询(URI,NULL,NULL,NULL,NULL);
 

关键点位置的URI 内容://彩信,短信/通话简单= TRUE

We run into the following crash when we attempt to query "content://mms-sms/conversations/" on a Samsung Galaxy S3 (Android 4.0.4) running on the Sprint network. Our calling code:

    Uri uri = Uri.parse("content://mms-sms/conversations/");

    Log.e("IL", "CONTENT MIME " + context.getApplicationContext().getContentResolver().getType(uri));

    // The next call crashes...
     Cursor cursor = context.getApplicationContext().getContentResolver().query(uri, null, null, null, null);

The interesting fact is that the log above returns

    CONTENT MIME vnd.android-dir/mms-sms

as expected.

Stack trace below:

Caused by: java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1333)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:182)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
at android.content.ContentProviderClient.query(ContentProviderClient.java:50)
at com.ilyngo.sms.model.MessageCatalog.refresh(MessageCatalog.java:107)
at com.ilyngo.sms.model.MessageCatalog.getSharedCatalog(MessageCatalog.java:58)
at com.ilyngo.sms.model.ContactsManager.clearCaches(ContactsManager.java:31)
at com.ilyngo.sms.app.bill_test.ThreadListActivity.onResume(ThreadListActivity.java:57)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
at android.app.Activity.performResume(Activity.java:4544)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
... 12 more
java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1333)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:182)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
at android.content.ContentProviderClient.query(ContentProviderClient.java:50)
at com.ilyngo.sms.model.MessageCatalog.refresh(MessageCatalog.java:107)
at com.ilyngo.sms.model.MessageCatalog.getSharedCatalog(MessageCatalog.java:58)
at com.ilyngo.sms.model.ContactsManager.clearCaches(ContactsManager.java:31)
at com.ilyngo.sms.app.bill_test.ThreadListActivity.onResume(ThreadListActivity.java:57)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
at android.app.Activity.performResume(Activity.java:4544)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2486)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2000)
at android.app.ActivityThread.access$600(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
解决方案

Issue can be resolved using simplified version of query:

Uri.parse("content://mms-sms/conversations?simple=true");
Cursor cursor = context.getApplicationContext().getContentResolver().query(uri, null, null, null, null);

Keypoint here's URI content://mms-sms/conversations?simple=true.

这篇关于彩信内容提供商发行(三星Galaxy S3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-19 00:18