Recent searches
No recent searches
Why is onBackPressed invalid in Activity?
Posted Jul 13, 2024
When I created a new project and it ran normally, I added the onBackPressed method in the Activity and canceled super. onBackPressed() to make the return button unavailable. Everything was fine now
But when I added it in build.gradle
implementation("zendesk.messaging:messaging-android:2.20.1")
At this point, press the return button again and the program exits. Why is this?
Why does this only happen in Android 14?

0
4
4 comments
Rachelle Felzien
Hello! We had a similar issue on my team, although we make a React Native app, where the Zendesk SDK is set up as native modules. We have a lot more going on under the hood with React Native navigation and stack management. However, I think the commonality is that the Zendesk Android SDK from version 2.19.0 onward appears to have a new back nav implementation that basically hijacks your app's back press events. Our team had to revert to `"zendesk.messaging:messaging-android:2.18.0"` in order to get our back press functionality working again.
0
Rachelle Felzien
Hello! We had a similar issue on my team, although we make a React Native app, where the Zendesk SDK is set up as native modules. We have a lot more going on under the hood with React Native navigation and stack management. However, I think the commonality is that the Zendesk Android SDK from version 2.19.0 onward appears to have a new back nav implementation that basically hijacks your app's back press events. Our team had to revert to `"zendesk.messaging:messaging-android:2.18.0"` in order to get our back press functionality working again.
0
Jesús Manzano Camino
If it helps, we've faced the same issue while working on this SDK bump and after some research, we found out that the problem is a change within the Zendesk SDK manifest file, enabling predictive back gesture (more info about it in https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture).
This change forces any consumer project to use the new back gesture APIs, disabling the old “onbackpressed” from activity/dialogs.
In order to revert such behaviour change, you can add this within your project manifest file, at
application
level:tools:replace="android:enableOnBackInvokedCallback"
android:enableOnBackInvokedCallback="false"
tools:targetApi="tiramisu"
This should let you still use the old
onBackPressed
API. We've already warned Zendesk support team about it, hopefully it will be fixed soon.1
Biconomy English
Thank you very much. I tried to add the following code in application to solve my problem
tools:replace="android:enableOnBackInvokedCallback"
android:enableOnBackInvokedCallback="false"
tools:targetApi="tiramisu"
0