【问题标题】:Android resolveuri failed on bad bitmap uriAndroid resolveuri 在错误的位图 uri 上失败
【发布时间】:2015-04-28 10:31:28
【问题描述】:

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

【问题讨论】:

标签: android image bitmap upload uri


【解决方案1】:

现在可以使用了。刚刚改了这个:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-30
    • 2014-07-16
    • 1970-01-01
    相关资源
    最近更新 更多