Android Back Button and Enterprise Browser

Pietro Francesco Maggi -
3 MIN READ
94
2

Edit

Enterprise Browser v1.3 introduced a change that requires to enable FunctionKeysCapturable to be able to use the KeyCapture API.

 

 

Updating your config.xml with this option will enable the KeyCapture API.

 

 

Enterprise Browser

Enterprise Browser is Zebra Technologies' Industrial Browser built for our Rugged Devices, we support most of our Windows Mobile/Windows CE devices and Android devices.

This product is usually used with existing web application that cannot be updated/modified moving from one device to another. This help us winning some opportunities but sometimes present some unique challenges like, as an example, disabling the Android back button default behaviour.

 

Back Button on Android?

Given that this is a crossplatform product (built on top of our RhoMobile Suite) we don't have a custom settings to disable the back button in the Config.xml configuration file, however it is still possible to add a default Metatags in the configuration so that no changes in the existing pages are needed.

So, do we've an API to intercept the Back Button?

Of course! the KeyCapture API can be used to intercept and disable it.

 

EB.KeyCapture.captureKey(BOOLEAN dispatch, STRING keyValue)    

 

Setting the dispatch value to false, We just need to get the correct KeyCode.

This can a bit tricky and can be different from device to device, the best solution I've is to ask directly to the device with a simple HTML page that display the keycode off all the keys that are pressed:

 

            Display KeyCode           

Press a key to see it's KeyCode

    

 

Once we've the correct KeyCode, we just need to call this API in every page that is loaded in the browser… Sometimes that is not easy to do sometimes, especially when the application cannot be modified.

We've a solution for this issue: having a DefaultMetaTags in Enterprise Browser's configuration.

 

What's a DefaultMetaTags

We can start from the documentation, what does it means?

A DefaultMetaTags is a way to call an Enterprise Browser API on top of every HTML page that is loaded in the browser. This can be used, as an example to enable on screen UI elements like the battery or WiFi icon.

So, putting the different things together, we can put this in the ''Config.xml':

 

          

 

BTW: 0xA6 is the correct value for the Back Button on a TC55 running Android v4.4 KitKat.

 

Closing comments

Enterprise Browser's DefaultMetaTags is a very flexible way to "patch" an existing Web application without touching its source code.

As a closing comment here's a sample configuration that zoom the current webpage pressing a button:

 

    

 

This post has been reposted from my personal website.

profile

Pietro Francesco Maggi

Please Register or Login to post a reply

2 Replies

R Ronald Elfferich

Hello,
I have applied this solution to disable the back button on an MC40 (android 4.4, EB 1.4). The normal back function is indeed disabled using the metatag solution. However, doing a long press on the hardware button still works (default behaviour is to go back one page in EB).
Is there a way to prevent this as well? I have tried a metatag with keyvalue = 'all' (

)
but this does not disable the long press function.
Thanks in advance!

P Pietro Francesco Maggi

Thank Ronald for reporting this.

we are investigating the issue.

~Pietro