Catch ActivityNotFoundException when saving image.

This commit is contained in:
akwizgran
2022-04-17 11:59:00 +01:00
parent 74a3f54d28
commit bc013296f6
2 changed files with 11 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
package org.briarproject.briar.android.conversation;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
@@ -263,7 +264,11 @@ public class ImageActivity extends BriarActivity
if (SDK_INT >= 19) {
String name = viewModel.getFileName() + "." +
getVisibleAttachment().getExtension();
launcher.launch(name);
try {
launcher.launch(name);
} catch (ActivityNotFoundException e) {
viewModel.onSaveImageError();
}
} else {
viewModel.saveImage(getVisibleAttachment());
}

View File

@@ -186,6 +186,11 @@ public class ImageViewModel extends DbViewModel implements EventListener {
}
}
@UiThread
void onSaveImageError() {
saveState.setEvent(true);
}
/**
* Saves the attachment on external storage,
* assuming the permission was granted during install time.