Phone-gap Plugin Development
Hello all, Here is a simple tutorial to create plugin for phone-gap from android studio.
Requirements :-
- Cordova (should be installed on your development machine).
- Phonegap (should be installed on your development machine).
Steps :-
1. Create following directory structure for plugin.
xyxplugin
- src
-abc.java
-www
xyzplugin.js
-plugin.xml
- in the above file structure "xyzplugin" is the name of your plugin and root folder of the same
- src is the folder which contains all your java files.
- abc.java is the java file which will be used by plugin.
- www is the folder which contains the js of the plugin.
- xyzplugin.js is the js file for the plugin.
- plugin.xml is the file that will be used at the time of integration of plugin to the phonegap project.
Your plugin's java file must extend cordova in-order to create communication between cordova and native code.
The Name of the class would be same which is being called from the js example.
cordova.exec(successCallback, errorCallback, "VideoPlugin", "initializeVideoCalling", [object]);
here VideoPlugin is the name of the class that extends cordova and initializeVideoCalling is the action which native will get as string in action parameter of the execute method of the Videocalling activity.
plugin.xml File contains all the rules and export statement for all resources and files that will be used in the project.
That's it just write the command to install the plugin and you are done.
cordova plugin add "location of your pluign"
For detailed understanding you can check out this link.
Happy Coding :)
0 Comment(s)