我使用Changelog
中的简易内容提供商在我的build.gradle中:
public void smsOnClick (View view){
TelephonyProvider telephonyProvider = new TelephonyProvider(this);
List<Thread> threads = telephonyProvider.getThreads().getList();
}
我想获得所有短信线程。 我使用此代码(来自here):
FATAL EXCEPTION: main
Process: com.daandtu.chat, PID: 3420
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:4054)
at android.view.View.performClick(View.java:4809)
at android.view.View$PerformClick.run(View.java:20123)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5536)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4049)
at android.view.View.performClick(View.java:4809)
at android.view.View$PerformClick.run(View.java:20123)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5536)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.os.Parcel.readException(Parcel.java:1546)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:420)
at android.content.ContentResolver.query(ContentResolver.java:490)
at android.content.ContentResolver.query(ContentResolver.java:434)
at me.everything.providers.core.AbstractProvider.getContentTableData(AbstractProvider.java:29)
at me.everything.providers.android.telephony.TelephonyProvider.getThreads(TelephonyProvider.java:98)
at com.daandtu.chatexport.MainActivity.smsOnClick(MainActivity.java:145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4049)
at android.view.View.performClick(View.java:4809)
at android.view.View$PerformClick.run(View.java:20123)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5536)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
但是虽然我有与wiki中相同的代码,但我得到了这个例子:
{{1}}
我的代码出了什么问题? 谢谢你的帮助