0
ich die „Photofile“ bin immer null in onActivityResult()android: Bildaufnahme von Kamera ein Null es bekommen
auf Aufnahmetaste klicken ich eine Methode dispatchTakePictureIntent() aufrufen Aber wenn ich es null bekommen wieder zurück .
Dieses Problem ist dann auftreten, wenn die Bildauflösung/Größe wie 4012 * 4012 usw. Sehr groß ist und speziell geschehen auf Android-Version 6.0 +
Hier ist mein Code
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = Util.createImageFile();
mCurrentPhotoPath = photoFile.getAbsolutePath();
System.out.println("photoFile:" + photoFile.getAbsolutePath());
} catch (IOException ex) {
ex.printStackTrace();
}
// Continue only if the File was successfully created
if (photoFile != null) {
System.out.println("@@@@ photoFile: " + photoFile.getAbsolutePath());
/*takePictureIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT,1024);
takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
mCurrentPhotoPath);*/
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_CANCELED) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
try {
//Bundle extras = data.getExtras();
// Log.i(TAG, "extras: " + extras.get("data"));
Bitmap mphoto = (Bitmap) data.getExtras().get("data");
System.out.println("***photoFile: " + data.getExtras().get("data"));
} catch (Exception e) {
// Log.i(TAG, "Exception:" + e.getMessage());
}
ShowPopupDialog(mCurrentPhotoPath);
}
}
}
Bitte mir helfen. Danke im Voraus.
posten Sie Ihre Fehler msg –
Fehler ist: Kann Stream dekodieren: java.lang.NullPointerException: Der Versuch, virtuelle Methode aufzurufen ‚char [] java.lang.String. toCharArray() 'für einen Null-Objektverweis – SAndroidD