私は、ルート化された Android 2.3.3 htc 信じられないほどの S センス 2.1 で MMS/SMS アプリケーションを作成しています。今、SMS/MMS の特定の連絡先リストを受信しようとしているときに、クエリで FC を取得します。
ここにいくつかのコードがあります:
Uri uri = Uri.parse("content://mms-sms/conversations/"+String.valueOf(thread_id));
ContentResolver cr = context.getContentResolver();
Cursor c= cr.query(uri,null,null,null,null); //crashing here
ログキャット:
05-22 15:24:24.273: E/AndroidRuntime(32087): FATAL EXCEPTION: main
05-22 15:24:24.273: E/AndroidRuntime(32087): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uiu.messaging/com.uiu.messaging.ContactMessageChain}: java.lang.NullPointerException
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.os.Looper.loop(Looper.java:143)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.ActivityThread.main(ActivityThread.java:4196)
05-22 15:24:24.273: E/AndroidRuntime(32087): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 15:24:24.273: E/AndroidRuntime(32087): at java.lang.reflect.Method.invoke(Method.java:507)
05-22 15:24:24.273: E/AndroidRuntime(32087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-22 15:24:24.273: E/AndroidRuntime(32087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-22 15:24:24.273: E/AndroidRuntime(32087): at dalvik.system.NativeStart.main(Native Method)
05-22 15:24:24.273: E/AndroidRuntime(32087): Caused by: java.lang.NullPointerException
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.os.Parcel.readException(Parcel.java:1328)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:372)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.content.ContentProviderProxy.query(ContentProviderNative.java:408)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.content.ContentResolver.query(ContentResolver.java:264)
05-22 15:24:24.273: E/AndroidRuntime(32087): at com.uiu.messaging.Data.getContactChain(Data.java:319)
05-22 15:24:24.273: E/AndroidRuntime(32087): at com.uiu.messaging.ContactMessageChain.onCreate(ContactMessageChain.java:138)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
05-22 15:24:24.273: E/AndroidRuntime(32087): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
05-22 15:24:24.273: E/AndroidRuntime(32087): ... 11 more
すべての権限が考慮されます。
どんな助けでも大歓迎です。
編集:
Mike の提案に従った後、logcat に次のエラーが表示されます。
05-22 16:31:46.178: E/AndroidRuntime(1892): FATAL EXCEPTION: main
05-22 16:31:46.178: E/AndroidRuntime(1892): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uiu.messaging/com.uiu.messaging.ContactMessageChain}: android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT * FROM (SELECT DISTINCT date * 1 AS normalized_date, NULL AS * FROM sms WHERE (htc_category= 0 AND thread_id = 25 AND (type != 3 AND type > 0)) UNION SELECT DISTINCT date * 1000 AS normalized_date, NULL AS * FROM pdu LEFT JOIN pending_msgs ON pdu._id = pending_msgs.msg_id WHERE (htc_category= 0 AND thread_id = 25 AND msg_box != 3 AND (msg_box > 0 AND msg_box != 3 AND (m_type = 128 OR m_type = 132 OR m_type = 130))) ORDER BY normalized_date ASC)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.os.Looper.loop(Looper.java:143)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.ActivityThread.main(ActivityThread.java:4196)
05-22 16:31:46.178: E/AndroidRuntime(1892): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 16:31:46.178: E/AndroidRuntime(1892): at java.lang.reflect.Method.invoke(Method.java:507)
05-22 16:31:46.178: E/AndroidRuntime(1892): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-22 16:31:46.178: E/AndroidRuntime(1892): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-22 16:31:46.178: E/AndroidRuntime(1892): at dalvik.system.NativeStart.main(Native Method)
05-22 16:31:46.178: E/AndroidRuntime(1892): Caused by: android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT * FROM (SELECT DISTINCT date * 1 AS normalized_date, NULL AS * FROM sms WHERE (htc_category= 0 AND thread_id = 25 AND (type != 3 AND type > 0)) UNION SELECT DISTINCT date * 1000 AS normalized_date, NULL AS * FROM pdu LEFT JOIN pending_msgs ON pdu._id = pending_msgs.msg_id WHERE (htc_category= 0 AND thread_id = 25 AND msg_box != 3 AND (msg_box > 0 AND msg_box != 3 AND (m_type = 128 OR m_type = 132 OR m_type = 130))) ORDER BY normalized_date ASC)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:372)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.content.ContentProviderProxy.query(ContentProviderNative.java:408)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.content.ContentResolver.query(ContentResolver.java:264)
05-22 16:31:46.178: E/AndroidRuntime(1892): at com.uiu.messaging.Data.getContactChain(Data.java:318)
05-22 16:31:46.178: E/AndroidRuntime(1892): at com.uiu.messaging.ContactMessageChain.onCreate(ContactMessageChain.java:138)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
05-22 16:31:46.178: E/AndroidRuntime(1892): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
05-22 16:31:46.178: E/AndroidRuntime(1892): ... 11 more
SQL文の何が問題なのかわかりません...