Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Extending your Cordova Android application with a native plugin


Android devices have been proven to be developer friendly insofar as they easily allow us to test and deploy unsigned applications throughout the development process.

How to do it...

In this recipe, we will create a native Android plugin for our Cordova application, using command-line tools as suggested by Cordova:

  1. Create a new directory named helloplugin. Then, create two blank directories, www and src, from the root. Next, create an empty file called plugin.xml. Now, we have a Cordova plugin project to get started, as shown here:

  2. We open plugin.xml and paste the following code for basic information about the plugin that we are going to make:

    <?xml version="1.0" encoding="utf-8"?>
    <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
            id="com.example.hello"
            version="0.7.0">
    
      <name>Hello</name>
    
      <engines>
        <engine name="cordova" version=">=3.4.0"/>
      </engines>
    ...