Bugfix: prevent crash when creating a marker (no camera or gallery application present).

Fixes #1561.
This commit is contained in:
Dennis Guse
2023-05-13 13:27:28 +02:00
parent a571c4c93b
commit 29568d0e3f
3 changed files with 16 additions and 2 deletions
@@ -16,6 +16,7 @@
package de.dennisguse.opentracks.ui.markers;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
@@ -244,7 +245,12 @@ public class MarkerEditActivity extends AbstractActivity {
private void createMarkerWithPicture() {
Pair<Intent, Uri> intentAndPhotoUri = MarkerUtils.createTakePictureIntent(this, getTrackId());
cameraPhotoUri = intentAndPhotoUri.second;
takePictureFromCamera.launch(intentAndPhotoUri.first);
try {
takePictureFromCamera.launch(intentAndPhotoUri.first);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.no_compatible_camera_installed, Toast.LENGTH_LONG).show();
}
}
private void createMarkerWithGalleryImage() {
@@ -256,6 +262,10 @@ public class MarkerEditActivity extends AbstractActivity {
intent = new Intent(Intent.ACTION_GET_CONTENT);
}
intent.setType("image/*");
takePictureFromGallery.launch(intent);
try {
takePictureFromGallery.launch(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.no_compatible_gallery_installed, Toast.LENGTH_LONG).show();
}
}
}