Practical No.1: Cordova Basics and Configurations
Practical No.1: Cordova Basics and Configurations
Practical No.1: Cordova Basics and Configurations
Index.html
<body>
<div class="app">
<h1>Hello World</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
</body>
The file contains all the configuration elements related to our project. We can also change the
configuration here in this file as per our requirement.
Config.xml
<?xml version='1.0' encoding='utf-8'?>
<name>HelloApp</name>
<description>
</description>
</author>
<platform name="android">
</platform>
<platform name="ios">
</platform>
</widget>
document.addEventListener("volumeupbutton",volUpFunction, false);
document.addEventListener("volumedownbutton",volDownFunction, false);;
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
function volUpFunction()
{
Path of Apk
D:\demo\EveFun\platforms\android\app\build\outputs\apk\debug
Open index.html
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<button id = "HelloWorld">Click Me</button>
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
Open index.js
onDeviceReady: function()
{
document.getElementById("HelloWorld").addEventListener("click",
sayHello);
this.receivedEvent('deviceready');
},
function sayHello()
{
alert('Welcome to The World Of Mobile Programming......');
};
app.initialize();
D:\demo\ButtonCP\platforms\android\app\build\outputs\apk\debug
Installing Plugman.
Installing Plugins.
function addContact()
{
var contact=navigator.contacts.create();
contact.displayName="Tushar";
contact.nickname="Tushar";
contact.name="Tushar";
P a g e | 28 SYBSc(IT) SEM – III MOBILE PROGRAMMING
contact.save(contactSuccess,contactError);
function contactSuccess
{alert("Contact saved!")
}
function contactError(message)
{alert('Failed because:' +message);
}
};
function searchContact()
{
var myContact=navigator.contacts.create({"displayName":"Test User"});
var options = new ContactFindOptions();
options.filter="Tushar";
options.multiple=true;
options.desiredFields=[navigator.contacts.fieldType.id];
options.hasPhoneNumber=false;
var fields=[navigator.contacts.fieldType.displayName,navigator.contacts.
fieldType.name];
navigator.contacts.find(fields,onSuccess,onError,options);
function onSuccess(contacts)
{alert('Found' +contacts.length+'contacts.');
};
function onError(contactError)
{alert('onError!');
};
};
app.initialize();