Android resolveuri在错误的位图uri上失败

时间:2015-04-28 10:31:28

标签: android image bitmap upload uri

我是android的新手,试图从画廊上传图像。似乎我得到的路径很好,但我不确定是否正确使用它来上传图像。

logcat说:resolveUri在坏位图uri上失败:[/storage/sdcard0/VK/FjKgT9DodNM.jpg,2130837564,2130837563,2130837565,2130837566]。

关于我做错什么的任何想法?

booksCovers这里是带有图片的对象的ArrayList。

    @Override
public boolean onContextItemSelected(MenuItem item) 
{
    switch (item.getItemId()) {
    case R.id.change_picture:
        onChangePictureClick();
        break;
    case R.id.delete_element:
        /*
        ...
        */
        break;
    default:
        break;
    }
    return super.onContextItemSelected(item);
};

private void onChangePictureClick()
{
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), CHANGE_PICTURE);
}

    @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) 
{
    getMenuInflater().inflate(R.menu.list_view_contex_menu, menu);
    info = (AdapterView.AdapterContextMenuInfo) menuInfo;// contains information about object of which ContextMenu was called from
};

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    if (resultCode == RESULT_OK)
    {
        switch (requestCode) 
        {
        case INPUT_ACTIVITY:
            /*
            ...
            */
            break;
        case CHANGE_PICTURE:
            Uri selectedImage = data.getData();
            String[] filePathColumn = {MediaStore.Images.Media.DATA};
            Cursor cursor = getContentResolver().query(selectedImage, 
                    filePathColumn, null, null, null);
            cursor.moveToFirst();
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String picturePath = cursor.getString(columnIndex);
            cursor.close();

            booksCovers.set(info.position, picturePath);
            HashMap<String, Object> hashMap = booksArray.get(info.position);
            hashMap.remove(coverkey);
            hashMap.put(coverkey, booksCovers);
            booksArray.set(info.position, hashMap);
            listAdapter.notifyDataSetChanged();
        }
    }
};

1 个答案:

答案 0 :(得分:0)

现在就开始工作了。刚改变了这个:

hashMap.put(coverkey, booksCovers.get(info.position));