mikeflores2000
Posts: 0
Joined: Sun May 06, 2012 11:09 pm

How can i override the back key to return to last application and not exit?

I'm running Android 4.0 and my app results in hot links displayed in the output.
Clicking a hot link sends me to another page but clicking the back key totally exits application.
How can I intercept or handle the Android back key to return back to my Tiggzi application?
Backbutton event handler in Tiggzi IDE appears not to fire. What did I miss?
Last Active Activity involves package
com.tiggzi.project32447 which should spell out
public class MyTiggziActivity extends Activity {
...
}

At a lower level, I found some code from the SDK that may help:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_BACK) {
//do what you want
return true;
}
return super.onKeyDown(keyCode, event);
}

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How can i override the back key to return to last application and not exit?

The Backbutton event is from PhoneGap. Can you post the code you are running on the Backbutton event? Are you testing it via Tiggzi tester or installed the app on the phone?

mikeflores2000
Posts: 0
Joined: Sun May 06, 2012 11:09 pm

How can i override the back key to return to last application and not exit?

Works fine via Tiggzi tester on MacBook Pro Safari browser.
Testing app on Android device.

I'm looking at com.phonegap.plugins.childBrowser package in class ChildBrowser:

  • Checks to see if it is possible to go back one page in history, then does so.
    */
    private void goBack() {
    if (this.webview.canGoBack()) {
    this.webview.goBack();
    }
    }

    *** However the phone gap documentation is different ***
    http://docs.phonegap.com/en/1.7.0/cor...

    Full Example

    <!DOCTYPE html SYSTEM

    Cordova Back Button Example

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How can i override the back key to return to last application and not exit?

How do you test the back button in the browser..?

Tiggzi currently uses PhoneGap version 1.5.

mikeflores2000
Posts: 0
Joined: Sun May 06, 2012 11:09 pm

How can i override the back key to return to last application and not exit?

Actually I noticed the back button is greyed out in Safari and Firefox.
A new tab is opened so exiting it allows for return to app.

mikeflores2000
Posts: 0
Joined: Sun May 06, 2012 11:09 pm

How can i override the back key to return to last application and not exit?

I'm not sure if this behavior of exiting totally out upon tapping back key
is a bug and similar to another bug fixed by Phonegap 1.6:

http://phonegap.com/2012/04/11/phoneg...

Android
[CB-367] Back button event should fire on key up not key down
Also changed menu key and search key to be consistent.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How can i override the back key to return to last application and not exit?

The back button that you are trying to overwrite is the physical button on Android devices, not the browser back button. You should only test it on the actual device.

mikeflores2000
Posts: 0
Joined: Sun May 06, 2012 11:09 pm

How can i override the back key to return to last application and not exit?

Affirmative:
https://issues.apache.org/jira/browse...

fixed in Phonegap 1.7.0 ( Apache Cordova )

https://issues.apache.org/jira/browse...
fixed in Phonegap 1.6.1 ( Apache Cordova )
Impacts Samsung Focus.

Bug reproduced on Samsung Galaxy Nexus running ICS ( Android 4.0.2 )

mikeflores2000
Posts: 0
Joined: Sun May 06, 2012 11:09 pm

How can i override the back key to return to last application and not exit?

Any plans by Tiggzi to upgrade to Phonegap 1.7 where issues are resolved?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How can i override the back key to return to last application and not exit?

Yes, just no date yet (very busy with other things). You can always export the app source, and update PhoneGap manually.

Return to “Issues”