Skip to content

Commit

Permalink
Fix start-up crash on Android 14
Browse files Browse the repository at this point in the history
Close #619.
  • Loading branch information
Slion committed Mar 26, 2024
1 parent e4aef30 commit 5ed8150
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/src/main/java/fulguris/view/WebPageTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import fulguris.utils.*
import android.annotation.SuppressLint
import android.app.Activity
import android.app.DownloadManager
import android.content.Context
import android.content.IntentFilter
import android.content.SharedPreferences
import android.graphics.*
Expand Down Expand Up @@ -481,7 +482,14 @@ class WebPageTab(
private fun createDownloadListener() {
// We want to receive download complete notifications
iDownloadListener = LightningDownloadListener(activity)
webView?.setDownloadListener(iDownloadListener.also { activity.registerReceiver(it, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) })
webView?.setDownloadListener(iDownloadListener.also {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// We need to export it otherwise we don't get download ready notifications
activity.registerReceiver(it, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED)
} else {
activity.registerReceiver(it, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
}
})
}

/**
Expand Down

0 comments on commit 5ed8150

Please sign in to comment.