1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Properly check if file manager intent can be handled

This commit is contained in:
Felix Ableitner 2017-09-27 13:07:54 +09:00
parent 94d72d768f
commit dbd8818707

View file

@ -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<Folder> {
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();
}
});