Android 解析在错误的位图uri上失败



我是安卓新手,试图从图库中更新图像。似乎我得到的路径很好,但我不确定是否正确使用它来上传图像。

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

对我做错了什么有什么想法吗?

books封面 这里有一个带有图片的对象数组列表。

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

现在让它工作了。刚刚更改了这个:

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

最新更新