Handle missing backup location picker
Amolith
created 1 month ago
Catch ActivityNotFoundException when launching the backup location
picker. Devices without an OPEN_DOCUMENT_TREE handler now get the
existing no_application_found toast instead of crashing from the
preference tap.
Change summary
src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java | 8
1 file changed, 7 insertions(+), 1 deletion(-)
Detailed changes
@@ -1,6 +1,7 @@
package eu.siacs.conversations.ui.fragment.settings;
import android.Manifest;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
@@ -94,7 +95,12 @@ public class BackupSettingsFragment extends XmppPreferenceFragment {
}
private boolean onBackupLocationPreferenceClicked(final Preference preference) {
- this.pickBackupLocationLauncher.launch(null);
+ try {
+ this.pickBackupLocationLauncher.launch(null);
+ } catch (final ActivityNotFoundException e) {
+ Toast.makeText(requireActivity(), R.string.no_application_found, Toast.LENGTH_LONG)
+ .show();
+ }
return false;
}