Sabik
Sabik

Reputation: 1

back button of smartphone doesn't work

I am developing an app using MoSync SDK.

I have 5 pages. Whenever I try to return back to the previous one, my smartphone's back button doesn't work. I have used the following code:

//back button (on Android).
document.addEventListener(
    "backbutton",
    function()
    {
        window.history.back()
    },
    true
);   

// Close the application when the back key is pressed.
document.addEventListener(
    "backbutton",
    function()
    {
    mosync.app.exit();
    },
    false
);

Upvotes: -2

Views: 565

Answers (1)

Clayton Oliveira
Clayton Oliveira

Reputation: 643

You don't have to deal with it, but if you actually want to, this is the way:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
    if (keyCode == KeyEvent.KEYCODE_BACK ) {
        // do something on back.
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

Take a look at this link: http://developer.android.com/training/implementing-navigation/temporal.html

Upvotes: 0

Related Questions