Galeriden seçerek veya yakalayarak bir görüntü ayarlamak için 2 seçeneğim var."Cause by: java.lang.NullPointerException: uri" görüntüyü yakaladıktan sonra görüntüyü ayarlamaya çalışırken
kullanıcı galerisinden görüntüyü seçtiğinde, bir klank ImageView dönmek ve kullanıcı bunu yakalayan sonra görüntüyü ayarlamak çalıştığınızda uygulama çöker aşağıdaki hatayı veriyor: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.abc.xyz/com.abc.xyz.Activity}: java.lang.NullPointerException: uri
İşte
Ben seçici başlatılması ediyorum açıklanmıştır:
İşteprotected DialogInterface.OnClickListener mDialogListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
switch (position) {
case 0: // Take picture
Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePhotoIntent, TAKE_PHOTO_REQUEST);
break;
case 1: // Choose picture
Intent choosePhotoIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
choosePhotoIntent.setType("image/*");
startActivityForResult(choosePhotoIntent, PICK_PHOTO_REQUEST);
break;
}
}
};
Ben ImageView görüntüyü ayarlıyorum edebilirsiniz:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == PICK_PHOTO_REQUEST || requestCode == TAKE_PHOTO_REQUEST) {
if (data == null) {
// display an error
return;
}
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
// error on the line below
Cursor cursor = this.getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
//
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
Picasso.with(this)
.load(picturePath)
.into(hPic);
hPicTag.setVisibility(View.INVISIBLE);
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(getBaseContext(), "Something went wrong!", Toast.LENGTH_LONG).show();
}
}
beni burada yanlış olduğunu bildirin.
Sorunun hatalı biçimlendirilmesi için özür dilerim. Ben hala yeni başlayan biriyim.
.. http://stackoverflow.com/questions/33938665/android-integrating-gallery -functionality-with-camera-capture/33939277 # 33939277 –
Bu cevap benim için işi yaptı: http://stackoverflow.com/a/5991757/6144372 –