Cordova plugin exit for Android app

My-It took me long time before I could put this solution together, but God be the author and finisher of all knowledge.

How to exit an android app with a button in Cordova project, html, CSS javascript.

1. Install the plugin Using cordova command line.
Command : npm i install Cordova-plugin-exit
This command is subject to change you can search further for latest commands
2.add event listener to the page where you want to add the code.
Example
function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // Cordova is loaded and it is now safe to make calls Cordova methods
    //
    function onDeviceReady() {
        // Now safe to use the Cordova API
    }.
<body onLoad="onLoad() ">
3. Add the name of the plugin to your xml for the Cordova project.

4.Build the project using cordova build.
AT THIS stage the plugin will be installed in your project
.
5. Add all the scripts inside your www folder that is added by Cordova to your page where you want to add the exit button
Script linking
6. Create the exit button

7. Create a function for the exit button

8 link the button to the function

9.congratulations you have just Integrated exit plugin in your website.

For more follow us on Facebook

Comments