MobileBlazorBindings
MobileBlazorBindings copied to clipboard
Android back button in hybrid closes the app
Hi, of course the normal behavior is close the app on back button, so how to avoid this action and make it go to the previous page ?
Ah, you want Android Back button to navigate back in the Web View of the hybrid app?
Ah, you want Android Back button to navigate back in the Web View of the hybrid app?
Yes exactly
Got it, we'll have to take a look at this, I'm sure there's a way to do it.
Since it's a Webview , you can use javascript window.history.back() and override default back button press in Mainactivity.cs I hope it helps :)
@Eilon any update on this?
Thanks
@ozzioma no update at this time. For now this is considered a low priority item but if someone wants to investigate and propose a fix, we could certainly look at including the fix in the next update.
I know i'm kind of reviving an old issue, but i managed to handle the back button using Xamarin's OnBackPressed override in MainActivity.cs. It catches the event, and i use the already referenced hybrid project with a "bridge-like" singleton class which contains a reference to a navigation manager wrapper, which handles the history. It works properly, but it requires a loading screen which makes the injection of the service first, otherwise it throws "not initialized" error. Another problem occurs when you minimize and resume the app, you need to save the history somehow, or it resets. I'm going to try saving it through the OnSaveInstance override.