Blog

Android - Here's how to correctly configure the back button to navigate to the previous screen

There are two settings to set when we want to configure the back button on an Android device to navigate the user to the previous screen, rather than quit the running app. Which is the correct setting? In this post, we'll find out.

Microsoft recently introduced an experimental feature to configure the back button on Android so that it navigates the user to the previous screen, rather than quit the running app.

We enable this behaviour through the app settings, and my earlier post describes this feature in more detail:


Following a recent update to Power Apps, which momentarily caused a bug in the OnStart property of an app (http://powerappsguide.com/blog/post/bug-onstart-property-missing-from-designer), there is now the additional option to set the Back button behaviour through the app node.


This is very confusing, especially as we can enable conflicting settings in both areas. If we enable the back behaviour in one area but not the other, which setting takes precedence?

The "Android back button" in settings Vs "Back enabled" in the App properties

To find out the answer, I created tow apps - one where I enabled the "Android back button" option in the settings only, and the other where I enabled the "Back enabled" option through the App node only.

The result is that when I tested both of these apps, the back button on my Android device did not navigate to the previous screen, and instead prompted me to exit the app.

I then created an app with both settings enabled. At run time, this configuration behaved as expected, and the back button successfully navigated to the previous screen.

Conclusion

To enable the back navigation behaviour on an Android device, we must enable both the "Android back button" and the "Back enabled" settings.

I hope that when this feature moves from experimental to general release, we will be able to control this setting purely through the App property setting, which will avoid any confusion with conflicting settings.
Related posts