Phonegap onPause event was not working
===

I have developed an android app under phonegap.
I have used local notification plugin. I was trying to get notification from server when app activity was paused.

I tried in javascript:

    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//data.uid
                    });
                    }
                    }
                }
               });
    } , 10000);}


And in my main activity :


    @Override  public void onBackPressed() { moveTaskToBack(true);  return;  } }

To pause the event every time when the back button was pressed.


But when the app was getting paused by back button/end call button/screen lock the pause event was not working. I just get it work for only one time.


What I'm missing?