Skip to content

Commit

Permalink
[Fix] Adds export behavior on broadcastreceiver to avoid SDK 34 crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Valdez authored and Andy Valdez committed Feb 2, 2024
1 parent 7ee1ff0 commit 720e83e
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.app.DownloadManager
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.content.res.Resources
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.view.Gravity
Expand Down Expand Up @@ -1160,10 +1162,18 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
super.onStart()
dispatcher.register(this)
EventBus.getDefault().register(this)
activity?.registerReceiver(
readerFileDownloadManager,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
activity?.registerReceiver(
readerFileDownloadManager,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
ContextWrapper.RECEIVER_NOT_EXPORTED
)
} else {
activity?.registerReceiver(
readerFileDownloadManager,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
)
}
}

override fun onStop() {
Expand Down

0 comments on commit 720e83e

Please sign in to comment.