大家好,
我正试图从Dropbox“Camera upload”文件夹中获取图像并将该图像设置为android中的图像视图但应用程序强制突然关闭,我能够从SD卡和相机获取图像并能够将图像设置为ImageView ,但我的下一个需要是从Dropbox获取图像并将其设置为ImageView,但它不适合我,如果有人知道如何解决这个问题,那么请帮我解决这个问题。
我的代码如下:
我添加了微调器来从图库,相机和保管箱中选择图像,我可以从图库和相机中获取图像,但不能从保管箱中获取图像,请帮助解决此问题:
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
提前致谢。
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);
}
}
}
答案 0 :(得分:0)
// mnt / sdcard / Android / data是每个应用的私有空间,你无法从这个空间获取文件