-
Notifications
You must be signed in to change notification settings - Fork 831
[WIP] Add built-in support for OnBackPressedCallback on Android #21969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@copilot continue the implementation |
This implements the new OnBackPressedCallback mechanism required for Android 33+ where OnBackPressed is deprecated and Android 36+ where OnBackPressed is no longer called at all. The implementation: - Creates a custom SystemNavigationManagerBackPressedCallback that integrates with the existing SystemNavigationManager.BackRequested event - Registers the callback with OnBackPressedDispatcher in OnCreate() - If the back press is not handled by the app (RequestBack returns false), temporarily disables the callback and re-invokes the dispatcher to allow the default system behavior This ensures that Uno apps continue to work correctly with the hardware back button and predictive back gesture on all Android versions. Fixes https://github.com/unoplatform/uno/issues/#11748 Co-authored-by: MartinZikmund <[email protected]>
|
|
Address code review feedback by extracting SystemNavigationManagerBackPressedCallback into a shared helper class in Uno.UI.Helpers namespace. The class is shared between both the native Android and Skia Android implementations via: - Direct inclusion in Uno.UI.netcoremobile.csproj - Linked file in Uno.UI.Runtime.Skia.Android.csproj This eliminates code duplication and makes maintenance easier. Co-authored-by: MartinZikmund <[email protected]>
Implemented The implementation:
This ensures that Uno apps continue to work correctly with the hardware back button and predictive back gesture on all Android versions, including Android 36+ where Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21969/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21969/wasm-skia-net9/index.html |
|
The build 185388 found UI Test snapshots differences: Details
|
OnBackPressedis deprecated on Android and no longer triggered on Android 36+ApplicationActivity.Android.csandApplicationActivity.cs(Skia Android) both overrideOnBackPressedSystemNavigationManager.csprovidesRequestBack()method andBackRequestedeventBaseActivityclasses extendAndroidX.AppCompat.App.AppCompatActivitywhich inherits fromComponentActivityOnBackPressedCallbacksupport:OnBackPressedCallbackthat invokesSystemNavigationManager.RequestBack()OnBackPressedDispatcherinApplicationActivityOnBackPressedfor older Android versionsApplicationActivity.Android.cs(native) andApplicationActivity.cs(Skia)Fixes https://github.com/unoplatform/uno/issues/#11748
Original prompt
OnBackPressedCallbackon Android #11748💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.