fix: search: crash on unable to open

This commit is contained in:
Kagura 2024-11-08 13:39:14 +08:00
parent c3d8f75ee6
commit 36ccbadb7d

View file

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