Domanda

I'm trying to develop an android app with phonegap and LocalNotification plugin. I want to running my app in onPause , On my index.html

document.addEventListener("pause", onPause, false);

function onPause() { // Handle the pause event

setInterval( function() {
    Ext.data.JsonP.request({
            url: 'http://convert4mobile.net/backend/API/qr/push.php',
            callbackKey: 'callback',
            success: function(data)
            {

                if(data.success == true)
                {
                    if (typeof plugins !== "undefined") {
              window.plugins.localNotification.add({
                        date : new Date(),
                        message : data.time+"\r\n"+data.msg,
                        ticker : "A new code was generated",
                        repeatDaily : false,
                        id : 4
                });
                }
                }
            }
           });
} , 2000);

}

It works fine when the app was closed/minimized by home button/end call button. I want to do the same thing by BackButton tapping. Any idea??

È stato utile?

Soluzione

Enter whatever code you want in this method:

@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();
}

Tutorial Here: http://chrisrisner.com/31-Days-of-Android--Day-10%E2%80%93The-Back-Button

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top