Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Docs
  • Loading branch information
GaryQian committed Sep 1, 2022
commit d6e915f10da66106d13674a274bfe5e510998675
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,16 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
configureStatusBarForFullscreenFlutterExperience();
}

/**
* Registers the callback with OnBackInvokedDispatcher to capture back navigation
* gestures and pass them to the framework.
*
* This replaces the deprecated onBackPressed method override in order to support
* API 33's predictive back navigation feature.
*
* The callback must be unregistered in order to prevent unpredictable behavior
* once outside the Flutter app.
*/
@VisibleForTesting
public void registerOnBackInvokedCallback() {
if (Build.VERSION.SDK_INT >= 33) {
Expand All @@ -514,6 +524,12 @@ public void registerOnBackInvokedCallback() {
}
}

/**
* Unregisters the callback from OnBackInvokedDispatcher.
*
* This should be called when the activity is no longer in use to prevent unpredictable
* behavior such as being stuck and unable to press back.
*/
@VisibleForTesting
public void unregisterOnBackInvokedCallback() {
if (Build.VERSION.SDK_INT >= 33) {
Expand Down