Skip to content

Commit

Permalink
Merge pull request #20116 from wordpress-mobile/andy/issue-19917-runt…
Browse files Browse the repository at this point in the history
…ime-broadcast

[Fix] Adds export behavior on broadcastreceiver to avoid SDK 34 crash.
  • Loading branch information
ravishanker authored Feb 4, 2024
2 parents ad69dd1 + 720e83e commit 2eff54c
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 2eff54c

Please sign in to comment.