成功调用“startActivityForResult”,但在活动之后和“onActivityResult”之前崩溃

时间:2012-02-17 13:53:56

标签: android

情景:

  • 第一个活动,调用我的第二个活动,请求结果如下:

    startActivityForResult(intent,1008);

  • 第二个活动(没有gui,没有xml文件等)启动正常

  • 第二个Activity调用联系人选择器请求结果,如下所示:

    Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent,1001);

  • 现在联系人选择器成功运行,但在选择联系人之后 它崩溃!

  

“应用程序......已意外停止”

我被困在那里几个小时,我已经浏览了stackoverflow并用Google搜索了它 - 我怎样才能防止它崩溃并从联系人选择器中获取结果? 它没有进入第二个应用程序的“onActivityResult”

第二项活动:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
    Toast.makeText(this, "A", Toast.LENGTH_SHORT).show();

    startActivityForResult(intent, CONTACT_PICKER_REQ_CODE);
    Toast.makeText(this, "B", Toast.LENGTH_SHORT).show();

}

我在屏幕上看到“A”和“B”祝酒词,在此期间看到联系人选择器,但在选择联系人后我收到了崩溃的消息......

logcat的:

02-17 15:10:39.747: E/AndroidRuntime(2303): FATAL EXCEPTION: main
02-17 15:10:39.747: E/AndroidRuntime(2303): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1001, result=-1, data=Intent { dat=content://com.android.contacts/contacts/lookup/0r2-473D433D3B2D5D5547/2 flg=0x1 (has extras) }} to activity {org.chaiware.contacts/org.chaiware.contacts.ContactInfoRetriever}: java.lang.IllegalArgumentException: the bind value at index 1 is null
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2574)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.ActivityThread.access$2000(ActivityThread.java:117)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:961)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.os.Looper.loop(Looper.java:123)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.ActivityThread.main(ActivityThread.java:3683)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at java.lang.reflect.Method.invokeNative(Native Method)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at java.lang.reflect.Method.invoke(Method.java:507)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at dalvik.system.NativeStart.main(Native Method)
02-17 15:10:39.747: E/AndroidRuntime(2303): Caused by: java.lang.IllegalArgumentException: the bind value at index 1 is null
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:144)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.content.ContentResolver.query(ContentResolver.java:262)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.Activity.managedQuery(Activity.java:1550)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at org.chaiware.contacts.ContactInfoRetriever.getContactInfo(ContactInfoRetriever.java:105)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at org.chaiware.contacts.ContactInfoRetriever.onActivityResult(ContactInfoRetriever.java:49)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.Activity.dispatchActivityResult(Activity.java:3908)
02-17 15:10:39.747: E/AndroidRuntime(2303):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)

0 个答案:

没有答案