Creating the mobile app on Apache Cordova

So, in order to create an app on Apache Cordova, all you need to do (if Apache Cordova is installed on your machine) is to execute this line of code:

sudo cordova create alert com.project.alert AlertTime

The app to create will be as simple as the following code:

<!DOCTYPE html>
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
        <title>Hello World</title>
        <div class="app">
            <h1>Motion detector</h1>
const req = new XMLHttpRequest();'GET', '', false);

so copy/paste this HTML code within the index.html file and save it.

once done perform:

sudo cordova platform add browser

This command will add the possibility to see how your app looks like. Then perform:

sudo cordova run browser

Your terminal will then indicate you the url at which you can reach your project, in my case http://localhost:8000.

Or you can run:

cordova add platform android

to add android, then:

cordova build android

to create the .apk file to transfer to your smartphone.

P.S: if you face some issues with Apache Cordova, you may have to run chown -R yourUserName /yourFolder

Last modified: Thursday, 6 February 2020, 9:36 PM