Java Android-onActivityResult-列数据无效

Java Android-onActivityResult-列数据无效,java,android,mobile,onactivityresult,Java,Android,Mobile,Onactivityresult,我正在尝试做一个发送短信和彩信的应用程序,所以我需要检索电话号码,最后是一张图片 我的问题是,如果我在onActivityResult中只选择了联系人案例,它工作正常,我得到了我的联系电话号码 但是如果我添加第二部分,选择图片,当我点击我的联系人时,我会得到一个: java.lang.IllegalArgumentException: Invalid column _data 但是我仍然可以毫无问题地拍照 双方意图通话 onActivityResult代码 我怎样才能解决这个问题呢?我实际上已

我正在尝试做一个发送短信和彩信的应用程序,所以我需要检索电话号码,最后是一张图片

我的问题是,如果我在onActivityResult中只选择了联系人案例,它工作正常,我得到了我的联系电话号码
但是如果我添加第二部分,选择图片,当我点击我的联系人时,我会得到一个:

java.lang.IllegalArgumentException: Invalid column _data
但是我仍然可以毫无问题地拍照

双方意图通话 onActivityResult代码
我怎样才能解决这个问题呢?

我实际上已经解决了

我只是忘记了
break:)

private static final int PICK_CONTACT = 3;
private static final int PICK_IMAGE   = 4;

protected void onCreate(Bundle savedInstanceState) {
    ...
}

public void addImage() {
    Intent choosePictureIntent = new Intent(Intent.ACTION_PICK,     android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(choosePictureIntent,PICK_IMAGE );
}
public void addContact(){
    Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
    startActivityForResult(intent, PICK_CONTACT);
}
public void onActivityResult(int reqCode, int resultCode, Intent data){
    super.onActivityResult(reqCode, resultCode, data);
    Uri contactData = data.getData();

    switch(reqCode) {
        case (PICK_CONTACT):
            if (resultCode == Activity.RESULT_OK) {
                ContentResolver cr = getContentResolver();
                Cursor cur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);

                if (cur.moveToFirst()) {

                    String id   = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
                    Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{id}, null);

                    while (pCur.moveToNext()) {
                        phone = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                        etPhoneNo.setText(phone);
                    }
                    pCur.close();
                }
            }
        case (PICK_IMAGE) :
            if (resultCode == Activity.RESULT_OK) {
                try {
                    BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
                    bmpFactoryOptions.inJustDecodeBounds = true;
                    bmpFactoryOptions.inSampleSize = 2;
                    bmpFactoryOptions.inJustDecodeBounds = false;
                    Bitmap bmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(contactData), null, bmpFactoryOptions);
                    imageView.setImageBitmap(bmp);
                } catch (FileNotFoundException e) {
                    Log.v("ERROR", e.toString());
                }

                ContentResolver cr = getContentResolver();
                String [] proj = {MediaStore.Images.Media.DATA};
                Cursor cursor = cr.query(contactData, proj, null, null, null);
                int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                cursor.moveToFirst();
                image_path = cursor.getString(column_index);
            }

    }
}