语言

Menu
Sites
Language
application exit when back button is pressed

Hi, 

 

i made web app which has web site on server-side.  

When I press back button to exit my app, my app moves into index page (index.html)  which is an empty page so I just can see white page, and then it needs to press back button one more for closing app. 

i just want to close my app without through passing any html page, How can I fix this problem? 

Please let me know. Thanks in advance. 

 

编辑者为: Soohong Min 10 12月, 2013

响应

6 回复
talari praveen kumar

Hi

In main.js you have code for handling back button, just modify it as shown below.

var backEvent = function(e) {

        if ( e.keyName == "back" ) {
             unregister();

   }

}

Soohong Min

Thank you for your reply. 

But it didn't work I got this error messag:

 ReferenceError: Can't find variable: unregister

 

talari praveen kumar

Hi

Try this

var backEventListener = null;

var unregister = function() {
    if ( backEventListener !== null ) {
        document.removeEventListener( 'tizenhwkey', backEventListener );
        backEventListener = null;
        window.tizen.application.getCurrentApplication().exit();
    }
}

//Initialize function
var init = function () {
    // register once
    if ( backEventListener !== null ) {
        return;
    }
       
    var backEvent = function(e) {
        if ( e.keyName == "back" ) {
             unregister();

        }
    }
    
    // add eventListener for tizenhwkey (Back Button)
    document.addEventListener( 'tizenhwkey', backEvent );
    backEventListener = backEvent;
};

Lakshmi Grandhi

you can do it using pagebeforeshow event

 

$( '#yourPage' ).live( 'pagebeforeshow',function(event){
   window.tizen.application.getCurrentApplication().exit();
});
Lakshmi Grandhi

modifies javacript code

$( '#yourPage' ).live( 'pagebeforeshow',function(event){
    window.tizen.application.getCurrentApplication().exit();
});

 

Andrew Richeson

Thanks Igrand to increase my knowledge you provide good solution