Android - onActivityResult - 列_data 无效

Android - onActivityResult - Invalid column _data

我正在尝试做一个发送 SMS 和 MMS 的应用程序,所以我需要检索 phone 号码并最终检索图像。

我的问题是,如果我在 onActivityResult 中只有 PICK_CONTACT 案例,它工作正常,我得到了我的联系方式phone 号。
但是如果我添加第二部分,PICK_IMAGE,当我点击我的联系人时,我得到一个 :

java.lang.IllegalArgumentException: Invalid column _data

但我仍然可以毫无问题地拍照..

双方意图调用

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);
}

onActivityResult 代码

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);
            }

    }
}

我该如何解决?

我居然解决了..

我忘了 break; :)