Skip to content

registerReceiver error after Android 33.#9

Open
endmr11 wants to merge 1 commit into
itisnajim:mainfrom
endmr11:main
Open

registerReceiver error after Android 33.#9
endmr11 wants to merge 1 commit into
itisnajim:mainfrom
endmr11:main

Conversation

@endmr11

@endmr11 endmr11 commented Oct 4, 2024

Copy link
Copy Markdown

Android 12 and later (API 31 and above): The RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED flag has become mandatory in these versions. If BroadcastReceiver will only be used within the application, Context.RECEIVER_NOT_EXPORTED is used. If exporting is required, Context.RECEIVER_EXPORTED can be used.

…EIVER_NOT_EXPORTED flag has become mandatory in these versions. If BroadcastReceiver will only be used within the application, Context.RECEIVER_NOT_EXPORTED is used. If it needs to be exported, Context.RECEIVER_EXPORTED can be used.
@itisnajim

Copy link
Copy Markdown
Owner

u have this check:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                    context.registerReceiver(appDeviceAdminReceiver, intentFilter, Context.RECEIVER_NOT_EXPORTED)
                }else {
                    context.registerReceiver(appDeviceAdminReceiver, intentFilter)
                }

so we can keep in build.gradle compileSdkVersion 31 instead of 33 ?

android {
    compileSdkVersion 31
    //compileSdkVersion 33
   ...

what do u think ?

@endmr11

endmr11 commented Oct 8, 2024

Copy link
Copy Markdown
Author

If the Context.RECEIVER_NOT_EXPORTED statement does not give an error, that parameter can remain as 31 at build time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants