Sunday 13 April 2014

How to Use Notification in Android using Phonegap API.

Hello Friends,


Today,  we are going to see how we can manage the dialogs or Notification in android using phonegap API.

For more videos please follow this channels
Please get the latest details about programming
visit our website
http://webconnect.0fees.net/

Create New Project called NotificationProject using Nodejs Command prompt.

1) Open Nodejs command Prompt and fire the below command.
cordova create NotificationProject web.connect NotificationProject
cd > NotificationProject
cordova platforms add android

cordova build




2) Add the dialog plugin to our project. Dont forgot to build after adding plugin to project
in the same directory

cordova plugin add "org.apache.cordova.dialog"



3) Import project to Eclipse. See this blog
4) Add button to your index.html page.

5) call a function ShowAlert on button click.


6) Add the following code to this function.

navigator.notification.alert("This is alert",null,"Information","OK");



7) For Confirm Dialog:
navigator.notification.confirm("Do you want to close this window?",result,"Confirmation","Yes,No");
function result(btnIndex) {
      if(btnIndex == 1) {
            navigator.notification.alert("You have clicked on Yes Button.",null,"Information","OK");
      }

}



8) For prompt dialog. This will prompt an alert and accepts the input from alert.
navigator.notification.prompt("Enter your Name?",result,"Get Name",['OK','Cancel'],"Default Name");
function result(returnValue) {
       navigator.notification.alert(returnValue,null,"Information","OK");

}


For more videos please follow this channels
Please get the latest details about programming
visit our website
http://webconnect.0fees.net/

Thank You
Abhishek Bendre


No comments:

Post a Comment