Nachdem Sie das Bild und klicken Sie auf die Schaltfläche "Absenden" die Galerie App abstürzt. Wie ist das möglich und wie kann ich es beheben? Die Galerie wird nie explizit in meiner App verwendet.Galerie abgestürzt nach der Aufnahme von Foto (Absicht)
Ich habe den MediaStore.ACTION_IMAGE_CAPTURE Intent verwendet, um die Kamera zu starten. Um das Bild auf das Dateisystem zu speichern ich den Code hier zur Verfügung gestellten verwendet:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
return;
}
// Continue only if the File was successfully created
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(getContext(),
"com.example.android.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK) {
File imgFile = new File(imagePath);
if(imgFile.exists()) {
if (HttpManager.isNetworkAvailable(getContext())) {
// Send the picture to the webserver (start AsyncTask)
} else {
// Save the call to process it later
}
}
}
}
Es: https://developer.android.com/training/camera/photobasics.html
Btw ich mit Android 4.1 (API 16)
-Code-Schnipsel ein Motorola TC55 bin mit Im Logcat sind keine Protokolle verfügbar, da meine App nicht abstürzt. Die einzigen Linien im logcat hinzugefügt, nachdem die Aktion begann, sind diese:
07-29 08:57:13.081 31473-31473/com.test.test W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
[ 07-29 08:57:13.081 180: 736 E/ ]
android::status_t android::QCameraStream_preview::getBufferFromSurface(): idx = 3, fd = 82, size = 462848, offset = 0
[ 07-29 08:57:13.091 180: 736 E/ ]
android::status_t android::QCameraStream_preview::getBufferFromSurface(): idx = 4, fd = 88, size = 462848, offset = 0
[ 07-29 08:57:13.091 180: 736 E/ ]
android::status_t android::QCameraStream_preview::getBufferFromSurface(): idx = 5, fd = 94, size = 462848, offset = 0
Manchmal wird diese bekomme ich nur:
07-29 09:01:19.464 12604-12604/com.test.test W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
Protokolle zur Verfügung stellen, bitte – ddb
Upload-Protokolle und den Code-Snipet, wo Sie die Absicht und die onActivityResult-Methode bitte erstellen. –
Code-Snippets hinzugefügt – wm377