皆さんこんにちは、
ドロップボックスの「カメラのアップロード」フォルダーから画像を取得しようとしていますが、その画像を Android の画像ビューに設定しようとしていますが、アプリケーションの強制終了が突然終了しました。SD カードとカメラから画像を取得し、その画像を ImageView に設定できますが、私の次に、ドロップボックスから画像を取得して 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);
}
}
}