From 36ccbadb7d8107dd7e8897ceb8068b0c9d04f5a3 Mon Sep 17 00:00:00 2001 From: Kagura Date: Fri, 8 Nov 2024 13:39:14 +0800 Subject: [PATCH] fix: search: crash on unable to open --- .../com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt b/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt index b2dff6a..e2284c9 100644 --- a/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt +++ b/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt @@ -1,5 +1,6 @@ package com.dazuoye.filemanager.compose.ui +import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent import android.widget.Toast @@ -195,7 +196,11 @@ class SearchFileColumn( val intent = Intent(Intent.ACTION_VIEW) intent.setDataAndType(uri, WrappedFile(file).mime) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - context.startActivity(intent) + try { + context.startActivity(intent) + }catch (e: ActivityNotFoundException){ + Toast.makeText(context,"无打开此应用的程序", Toast.LENGTH_SHORT).show() + } } } }