Skip to content

Commit 0611926

Browse files
committed
Catching IOExceptions during file extraction
1 parent ffcc752 commit 0611926

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/src/main/kotlin/com/glodanif/bluetoothchat/model/ApkExtractor.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ class ApkExtractor(private val context: Context) : FileExtractor {
2525
val file = File(application.applicationInfo.publicSourceDir)
2626

2727
thread {
28-
val newFile = copyAndZip(file, directory, "BluetoothChat")
29-
handler.post {
30-
onExtracted.invoke(Uri.fromFile(newFile))
28+
29+
try {
30+
val newFile = copyAndZip(file, directory, "BluetoothChat")
31+
handler.post {
32+
onExtracted.invoke(Uri.fromFile(newFile))
33+
}
34+
} catch (e: IOException) {
35+
onFailed.invoke()
3136
}
3237
}
3338

0 commit comments

Comments
 (0)