From dbd88187070c0e575a66b7b61cbcb988eb845674 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 27 Sep 2017 13:07:54 +0900 Subject: [PATCH] Properly check if file manager intent can be handled --- .../com/nutomic/syncthingandroid/views/FoldersAdapter.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java b/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java index 639260c4..8364ca05 100644 --- a/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java +++ b/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java @@ -1,6 +1,5 @@ package com.nutomic.syncthingandroid.views; -import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.databinding.DataBindingUtil; @@ -54,9 +53,9 @@ public class FoldersAdapter extends ArrayAdapter { binding.openFolder.setOnClickListener(v -> { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(folder.path)), "resource/folder"); - try { + if (intent.resolveActivity(getContext().getPackageManager()) != null) { getContext().startActivity(intent); - } catch (ActivityNotFoundException e) { + } else { Toast.makeText(getContext(), R.string.toast_no_file_manager, Toast.LENGTH_SHORT).show(); } });