简体   繁体   English

如何在Dropbox的Camera Upload文件夹中将图像设置为Android中的ImageView?

[英]How to Set image from Camera upload folder of dropbox to ImageView in android?

Hi Everyone, 嗨,大家好,

I am trying to get image from dropbox "Camera upload" folder and set that image to image view in android but application force closed suddenly, I am able to get image from sd card and camera and able to set that images to ImageView, but my next need is to get the image from dropbox and set it to the ImageView, but its not working for me, If anyone having idea how to resolve this issue then please help me to solve this issue. 我正在尝试从保管箱“ Camera Upload”文件夹中获取图像并将该图像设置为android中的图像视图,但是应用程序突然关闭,我能够从SD卡和相机中获取图像并将该图像设置为ImageView,但是我下一步需要从Dropbox获取图像并将其设置为ImageView,但对我不起作用,如果有人对如何解决此问题有任何想法,请帮助我解决此问题。

My Code is as below: 我的代码如下:

I added spinner to choose images from Gallery, Camera and dropbox, i am able to get images from gallery and camera but not from dropbox, please help to resolve this issue: 我添加了微调器以从图库,照相机和投递箱中选择图像,我能够从画廊和照相机获取图像,但不能从投寄箱中获取图像,请帮助解决此问题:

Error showing as fatal exception 
Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent
 { dat=file:///mnt/sdcard/Android/data/com.dropbox.android/files/scratch/Camera Uploads/2013-11-11 09.42.20.jpg typ=image/jpeg }} to activity {com.capstone.classitweetsdemo/com.capstone.classitweetsdemo.MainActivity}: java.lang.NullPointerException

Thanks in advance. 提前致谢。

spnImage.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

        if (spnImage.getSelectedItem().toString().equals("Select from Gallery")) {

            imageLayout.setVisibility(View.VISIBLE);

            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "Select image to upload."), RESULT_LOAD_IMAGE);
        } else if (spnImage.getSelectedItem().toString().equals("Capture Image")) {

            imageLayout.setVisibility(View.VISIBLE);

            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, CAMERA_REQUEST);
        }
    }


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

        if (requestCode == RESULT_LOAD_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]);
            picturePath = cursor.getString(columnIndex);
            cursor.close();

            imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));

            sldImgPic.setImageBitmap(BitmapFactory.decodeFile(picturePath));
        } else if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
            photo = (Bitmap) data.getExtras().get("data");
            imageView.setImageBitmap(photo);
        }
    }
}

// mnt / sdcard / Android / data是每个应用程序的专用空间,您无法从该空间获取文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从相机文件夹将图像设置为imageview - Set image into imageview from camera folder 如何在图库中的imageView上设置图像以及在Android中由相机拍摄的图像? - How to set an image on imageView from the gallery and image taken by camera in Android? 相机中的图像未设置为ImageView - Image from camera not set to ImageView 如何在特定的imageView上上传特定的图像从Android中的图库和相机单击 - How to upload particular image on particular imageView click from gallery and camera in android android-如何将图像上传到保管箱? - android - how to upload an image to dropbox? 从图库或相机设置图像以适合Imageview android - set image from Gallery or Camera to fit to Imageview android Android从ImageView上传图像 - Android upload image from ImageView 如何将以相机意图拍摄的图像设置为ImageView? - How can i set an image taken from the Camera intent into a ImageView? 从相机获取图像或从图库上传并在 ImageView (Android Studio) 中显示后,保存图像为 SharedPreferences - Save image is SharedPreferences after Image is get from camera or upload from gallery and display at ImageView (Android Studio) 如何在Android中将图像从可绘制图像设置为ImageView - How to set image from drawable into imageview in Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM