Skip to content

Fix cancel button functionality for Android 14+ - #21

Draft
codegen-sh[bot] wants to merge 1 commit into
mainfrom
codegen-bot/fix-cancel-button-functionality-1749411579
Draft

Fix cancel button functionality for Android 14+#21
codegen-sh[bot] wants to merge 1 commit into
mainfrom
codegen-bot/fix-cancel-button-functionality-1749411579

Conversation

@codegen-sh

@codegen-sh codegen-sh Bot commented Jun 8, 2025

Copy link
Copy Markdown

Problem

The cancel button in transfer notifications was not working on Android 14+ devices. This was due to changes in Android's broadcast receiver requirements that became mandatory starting with API level 34.

Root Cause

  1. Incorrect receiver export setting: The code was using RECEIVER_EXPORTED when it should use RECEIVER_NOT_EXPORTED for internal app communication
  2. Implicit intent delivery issues: The PendingIntent was using implicit intents which may not be delivered properly to dynamically registered receivers on newer Android versions

Solution

  • ✅ Changed RECEIVER_EXPORTED back to RECEIVER_NOT_EXPORTED since this is internal app communication that shouldn't receive broadcasts from external apps
  • ✅ Added setPackage(context.packageName) to the PendingIntent creation to make it explicit and ensure proper delivery
  • ✅ Cleaned up the broadcast receiver validation logic

Testing

This fix addresses the Android 14+ broadcast receiver requirements while maintaining backward compatibility. The cancel functionality should now work properly across all supported Android versions.

Files Changed

  • Android/app/src/main/java/de/canyumusak/androiddrop/TransferService.kt

Fixes the issue where users couldn't cancel file transfers from the notification on newer Android devices.


💻 View my workAbout Codegen

- Changed RECEIVER_EXPORTED back to RECEIVER_NOT_EXPORTED for internal app communication
- Added setPackage() to PendingIntent to make it explicit and ensure proper delivery
- Simplified broadcast receiver validation logic

This fixes the issue where the cancel button in notifications was not working
on newer Android versions due to stricter broadcast receiver requirements.
@CanYumusak
CanYumusak self-requested a review August 6, 2025 10:34
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.

0 participants