Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Is there a way to override a Back button press on Android?

$
0
0

I'm having issues with a ContentPage in my app. It consists of a WebView that fills the screen. There are links that users can click to be taken to different pages within the webview (these are all external URLs). But if you press the Back button on Android, the app navigates away from the web view page COMPLETELY, taking you back to the previous ContentPage (which unfortunately is almost always the login page, causing people to have to log back-in).

Is there a way to handle the Back button press and provide my own functionality? Ideally I'd like to first attempt to navigate back through the WebView's history (WebView has a GoBack() method), navigating to a different ContentPage ONLY if we're already at the beginning of the history.

This is possible with a "regular" Xamarin app (you can override an Activity's OnBackPressed() method), how can I handle it with Xamarin.Forms?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>