content:// mms-sms / conversations /在Android ICS Samsung上返回NullPointerException

前端之家收集整理的这篇文章主要介绍了content:// mms-sms / conversations /在Android ICS Samsung上返回NullPointerException前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在开发短信应用程序,需要列出短信对话.尝试使用uri内容访问内容提供程序时发现问题:// mms-sms / conversations /.它在 Android 2.3上运行良好,但在Android 4.0.3三星galaxy tab 2上运行时会返回错误
10-17 09:04:51.035: E/AndroidRuntime(22600): FATAL EXCEPTION: main
 10-17 09:04:51.035: E/AndroidRuntime(22600):
 java.lang.RuntimeException: Unable to start activity
 ComponentInfo{com.yooi/com.yooi.ui.MainActivity}:
 android.view.InflateException: Binary XML file line #6: Error
 inflating class fragment 10-17 09:04:51.035: E/AndroidRuntime(22600):
    at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.ActivityThread.access$600(ActivityThread.java:128) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.os.Handler.dispatchMessage(Handler.java:99) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.os.Looper.loop(Looper.java:137) 10-17 09:04:51.035:
 E/AndroidRuntime(22600):   at
 android.app.ActivityThread.main(ActivityThread.java:4514) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 java.lang.reflect.Method.invokeNative(Native Method) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 java.lang.reflect.Method.invoke(Method.java:511) 10-17 09:04:51.035:
 E/AndroidRuntime(22600):   at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 dalvik.system.NativeStart.main(Native Method) 10-17 09:04:51.035:
 E/AndroidRuntime(22600): Caused by: android.view.InflateException:
 Binary XML file line #6: Error inflating class fragment 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.view.LayoutInflater.inflate(LayoutInflater.java:489) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.view.LayoutInflater.inflate(LayoutInflater.java:396) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.view.LayoutInflater.inflate(LayoutInflater.java:352) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.Activity.setContentView(Activity.java:1835) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 com.yooi.ui.MainActivity.onCreate(MainActivity.java:17) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.app.Activity.performCreate(Activity.java:4465) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   ... 11 more 10-17
 09:04:51.035: E/AndroidRuntime(22600): Caused by:
 java.lang.NullPointerException 10-17 09:04:51.035:
 E/AndroidRuntime(22600):   at
 android.os.Parcel.readException(Parcel.java:1334) 10-17 09:04:51.035:
 E/AndroidRuntime(22600):   at
 android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.content.ContentResolver.query(ContentResolver.java:311) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 com.yooi.ui.SmsThreadListActivity.getThreadListCursor(SmsThreadListActivity.java:146)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 com.yooi.ui.SmsThreadListActivity.onCreateView(SmsThreadListActivity.java:95)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.FragmentManagerImpl.moveToState(FragmentManager.java:806)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1010)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1108)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   at
 android.app.Activity.onCreateView(Activity.java:4243) 10-17
 09:04:51.035: E/AndroidRuntime(22600):     at
 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
 10-17 09:04:51.035: E/AndroidRuntime(22600):   ... 21 more

我花了我的时间在谷歌搜索它但仍然没有找到答案.知道的任何人请帮助我,我被困在这个烦人的问题:(

解决方法

可以通过此查询检索对话列表:
Uri.parse("content://mms-sms/conversations?simple=true"); 
Cursor cursor = context.getApplicationContext().getContentResolver().query(uri,null,null);

Keypoint这里的URI内容:// mms-sms / conversations?simple = true.

here

原文链接:https://www.f2er.com/android/309501.html

猜你在找的Android相关文章