Android device Back button
I am developing an App using Sencha Touch 2. I have added routes in my controller as per instruction on http://docs.sencha.com/touch/2-0/#!/...istory_support. The App works properly on my desktop using Chrome Browser. I can navigate and also use Browser's back button to get back to previous page. I can also visit the App from my Android's Browser and navigate the App and use the device's back button properly.
However, when I package it as a native Android App, and try to navigate across the app, pressing the device back button exits from the program entirely, instead of going back to previous page/step. In other words, the device back button does not work when I package it as a native app, but seems to work properly when I visit the App from the Android's Browser.
I have tried it on both Android 2.2/2.3 and 4.0, and it's the same issue on both. Is there anything extra that needs to be done before packaging, to ensure the device back button works?
Any help would be appreciated?
Requires Phonegap or other way to handle device back button
From my findings, it seems Sencha Touch does not / cannot handle events triggered by device back button on Android when packaged as a Native App. Though, it handles it fine, when the App is visited from Android Browser.
So, to solve it, Phonegap could be added to the App which shall solve it. However, if only back button is required to be handled, then adding phonegap may be slightly overkill, so it may be easier to just create an Activity in Java and add WebView inside it. Then, loading index.html of Sencha App there. The second approach makes the app smaller, but requires experience with Java/Android.
More Info on WebView and how to load an html file can be viewed here on Android (2nd approach):
Hope it helps someone else out in similar situation.
Tags for this Thread