MMS CONTENT PROVIDER ISSUE (Samsung Galaxy S3)
Asked Answered
F

2

1

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)
Frumentaceous answered 30/9, 2012 at 19:1 Comment(0)
D
1

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.

Doronicum answered 30/11, 2012 at 7:38 Comment(0)
D
0

This ContentProvider does not accept a null projection. You have to provide it explicitly using "*" so it gets passed to the underlying SQL query statement:

final String[] proj = {"*"};
Cursor cursor = context.getApplicationContext().getContentResolver().query(uri, proj, null, null, null);

I guess this is a general Android issue.

Check this question: How to Read MMS Data in Android?

Downer answered 1/10, 2012 at 10:29 Comment(1)
Original developer here... We originally used the {"*"} projection and received the exact same crash. (That was our original implementation before reverting to a null projection to eliminate that as a potential cause.Curling

© 2022 - 2024 — McMap. All rights reserved.