本文介绍了匹克从android的图片库的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android.I天真现在面临一个 nuNullPointerException当我选择将图像从gallery.my code以下是这样的,在光标收到错误 filePathColumn [0] 。怎么办..

  @覆盖
  保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
    super.onActivityResult(要求code,结果code,数据);    如果(要求code == PICK_IMAGE&放大器;&安培;结果code == RESULT_OK
            &功放;&安培;空!=数据){
        乌里selectedImage = data.getData();
        的String [] = filePathColumn {MediaStore.Images.Media.DATA};        光标光标= getContentResolver()查询(selectedImage,
                filePathColumn,NULL,NULL,NULL);
        cursor.moveToFirst();
        INT参数:columnIndex = cursor.getColumnIndex(filePathColumn [0]);
        字符串picturePath = cursor.getString(参数:columnIndex);
        cursor.close();        德codeFILE(picturePath);    }
}


解决方案

而不是自己尝试它,看看最近的图像库。它可以帮助你。 是链接。

I am naive in android.I am facing a nuNullPointerException when i picking an image from the gallery.my code is following like that and getting error in cursor and filePathColumn[0]. What to do..

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PICK_IMAGE && resultCode == RESULT_OK
            && null != data) {
        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();

        decodeFile(picturePath);

    }
}
解决方案

Instead of trying it by yourself, take a look at recent-images library. It can help you. here is the link.

这篇关于匹克从android的图片库的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 06:13