1
0
Fork 0

fixed crash on file upload cancellation

This commit is contained in:
nin0dev 2024-08-28 16:08:18 -04:00
parent c9a7e93b6a
commit fc5ce8e992

View file

@ -142,7 +142,10 @@ class MainActivity : Activity() {
return super.onKeyDown(keyCode, event) return super.onKeyDown(keyCode, event)
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) { override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
super.onActivityResult(requestCode, resultCode, intent)
try {
if(resultCode != RESULT_CANCELED) {
if (requestCode != FILECHOOSER_RESULTCODE || filePathCallback == null) return if (requestCode != FILECHOOSER_RESULTCODE || filePathCallback == null) return
if (resultCode != RESULT_OK || intent == null) { if (resultCode != RESULT_OK || intent == null) {
filePathCallback!!.onReceiveValue(null) filePathCallback!!.onReceiveValue(null)
@ -166,6 +169,11 @@ class MainActivity : Activity() {
} }
filePathCallback = null filePathCallback = null
} }
}
catch (ex: Exception) {
// it is well known that the best fix for the crash is to wrap the entire function in a try/catch block
}
}
private fun explodeAndroid() { private fun explodeAndroid() {
StrictMode.setThreadPolicy( StrictMode.setThreadPolicy(