0
我有錯誤代碼光標光標= managedQuery(intent.getData().... NullPointerException異常
public void runIntent()
{
Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, 1);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if (resultCode == 0) {
getContactInfo(intent);
Log.e("RESULT_OK","Ok");
}else
{
Log.e("RESULT_OK","Error");
}
}//onActivityResult
和getContactInfo(意向)
public void getContactInfo(Intent intent)
{
Cursor cursor = managedQuery(intent.getData(), null, null, null, null); //i think error here becouse when i delete this i not have error.
cursor.close();
}
我不知道,但在這。funiction線光標=管理查詢...我有NullPointerException異常(((我不知道如何解決它
這裏從logcat中:
04-05 10:48:53.055: ERROR/AndroidRuntime(620): FATAL EXCEPTION: main
04-05 10:48:53.055: ERROR/AndroidRuntime(620): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {contactTest.com/contactTest.com.ContactTest}: java.lang.NullPointerException
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.ActivityThread.access$2800(ActivityThread.java:125)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.os.Looper.loop(Looper.java:123)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at dalvik.system.NativeStart.main(Native Method)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): Caused by: java.lang.NullPointerException
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at contactTest.com.ContactTest.getContactInfo(ContactTest.java:71)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at contactTest.com.ContactTest.onActivityResult(ContactTest.java:61)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.Activity.dispatchActivityResult(Activity.java:3890)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
04-05 10:48:53.055: ERROR/AndroidRuntime(620): ... 11 more
04-05 10:48:53.085: WARN/ActivityManager(60): Force finishing activity contactTest.com/.ContactTest
當意圖開始 - 我按Backbackton(在手機上),我在logcat中的錯誤,應用程序停止。請告訴我如何解決它,我看到很多帖子對這個論壇 - 但無法找到任何東西可以幫助我:( 的問候,彼得
非常感謝,真的幫助我,3分鐘後我可以接受(冷卻時間)謝謝:) – Peter 2011-04-05 11:08:46