What is the correct way to close the game on android?

  • So what i have been doing is using the browsers plugin close action. the thing is after i close the game if i restart the game a Software update needed Android system web view message shows up?

    So opening the app for the first time works properly, i use the browser close action (on android device) then i reopen the app and get the update needed.

    is there a different way to provide a close application on android??

    I was testing this on a Galaxy Note 9.

  • Hi, try use browser exec JS and insert this code:

    window.navigator.app.exitApp();
    
    or
    
    navigator.app.exitApp();
    
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Javanie

    Hi, try use browser exec JS and insert this code:

    > window.navigator.app.exitApp();
    
    or
    
    navigator.app.exitApp();
    

    The Browser plugin's Close action already does that.

    piranha305

    I'm afraid that's the recommended way. So, your problem might be caused by something else.

  • Javanie

    > Hi, try use browser exec JS and insert this code:

    >

    >

    > > window.navigator.app.exitApp();
    > 
    > or
    > 
    > navigator.app.exitApp();
    > 

    The Browser plugin's Close action already does that.

    I don't know if browser plugin's close action already does that, thanks for the information.

    piranha305

    Since you asking "for is there a different way to provide a close application on android?"

    and my first post is same as Browser plugin's close action navigator.app.exitApp(); then you can try the different way to close app on android below.

    If you want to try different method close the app,navigator.app.exitApp(); is close app programmatically maybe you want to try force stop app programmatically.

    You can export your project to android project then open CoreAndroid.java inside folder:

    your cordova project folder\platforms\android\CordovaLib\src\org\apache\cordova

    or if you export to cordova project then after cordova prepare go to folder:

    your cordova project folder\platforms\android\CordovaLib\src\org\apache\cordova

    search for:

     else if (action.equals("exitApp")) {
     this.exitApp();
     }
    

    Then replace code:

     else if (action.equals("exitApp")) {
     // this.exitApp();
    		cordova.getActivity().finishAffinity();
    		System.exit(0);
     }
    

    This will quit the app completely.

    You also can use this one, this will quit the app completely and remove from the recent tasks list:

     else if (action.equals("exitApp")) {
     // this.exitApp();
    		cordova.getActivity().finishAndRemoveTask();
    		System.exit(0);
     }
    

    Note:

    .finishAndRemoveTask(); if you use this you will need at least minimum API 21.

    If you use cordova.getActivity().finishAffinity(); or cordova.getActivity().finishAndRemoveTask(); without System.exit(0);

    app will quit but the allocated memory will still be in use by device then use System.exit(0); to completely clean allocated memory in use by your app then quit the app completely.

    To close app, just use browser close action this will execute cordova.getActivity().finishAffinity(); and System.exit(0);

    or if you use quit the app completely and remove from the recent tasks list will execute

    cordova.getActivity().finishAndRemoveTask(); and System.exit(0);

    Demo video:

    Subscribe to Construct videos now
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)