[英]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.