Implementing plugin in phonegap - android

I am developing android mobile application using phonegap.I want to implement “ContactPicker plugin“ from github webstie.For implement plugin I refered below article
"https://github.com/sconover/phonegap-android-plugin-examples"
In above article they explained the path of plugin, But on my machine I did not find the path
"src/com/phonegap/HelloWorldPlugin/HelloWorldPlugin.java” In my plugin. Also I was unable to get the file HelloWorldPlugin.java
I tried to install plugin using command line tool but not sure its installed or not.
I am unable to use this plugin in my phonegap application. I am stuckup with very basic step of copying files and using the same in phonegap.

Don't use old plugins, this one is about four years old. A lot of things changes since 2010.
Use the original cordova plugin: org.apache.cordova.contacts

Related

How can i add my custom cordova plugin in my android App?

I have a native android sdk which uses phone camera. I want to add a custom cordova plugin so that i can use that android code for web as well using plugins(google suggested it can be done). can someone please suggest me how it can be done?
I am able to create plugin but not able to add it to android code.
And from googling it is suggested that for that i need to create a cordova project first. I made a cordova project for testing purpose added platforms as-android, ios.
But I'm unable to get even the layout of that project so that i can even edit.
I have my native android code, please suggest me how can i add a cordova in native android project.

Is there a way to use android application functionality on cordova?

I have two applications one is running on android java,the other one is a cordova application. I need to use the android functionality on the cordova app. is therere a workround to this? I have been scratching my head for a week.
I have looked into Android plugins but i don't really know how to glue them together. I know Cordova can communicate back and forth with native code. But since i am an android developer and i have little idea on how cordova works with plugins Am Stuck with just my plain Android App built on java.
If you have a custom requirement, then your best shot is creating a plugin for Cordova which is well documented in the cordova docs. It will guide you on how to build as well as publish a plugin for Cordova.
Once you publish a plugin, you can add it using
cordova plugin add <plugin_name>

how to make a cordova android plugin using external non-builded lib (OpenCV)

I'm trying to create a cordova plugin to use OpenCV on android and iOS.
I am for the moment at the android part.
I downloaded the OpenCV android package, and create a test application with android. That work, so I just need to put that in the plugin.
But I have absolutly no idea about how to import the OpenCV library in the plugin.
Someone know how to do that ?
Thanks in advance
Have you written a cordova plugin in the past? If not, this is probably not the easiest place to start (if you haven't start with the plugin guide from the Cordova team.).
Including JNI (native code) in Android in Cordova plugins is a bit of black art, but you are lucky that someone has gone there before (and abandoned) a
Cordova OpenCV plugin for Android. Study that, and then for iOS it is a lot easier, since you can CocoaPods or just include the library and don't have to worry about C/Java bridge. If all of this is making your head hurt and you have no idea what JNI is then you might want to farm out the writing of this kind of plugin to someone else.
EDIT
I was going to add this in a comment but it was too long:
An apk is a complete App and not a Library.you need to include the various .so files (shared objects) for openCV. If you want to learn how to link a C++ file into an Android app (first step of creating a Cordova Plugin with JNI check out this tutorial. However, since half the work has already been done for you, what I would do is just download the OpenCV Plugin into a directory and then
cordova plugin install
and fix what you need (if you get everything working, think about forking the original project and contribute back to the community :) ).
As stated the plugin for iOS will be similar to other IOS plugins, maybe look at the cordova-cocoapods project, the other cordova-cocoapods project and the OpenCV CocoaPod.

Difference between PhoneGap and Cordova and which one should we install?

I have been tasked with developing an Android and iOS application with PhoneGap (http://phonegap.com/)
However, as I read, things start to get really complicated: Some people say Cordova (http://cordova.apache.org/) is now PhoneGap, others say PhoneGap is just a distribution of PhoneGap.I lost 3 days and still can't find a proper way or a guide to install a fully functional PhoneGap plugin either in Eclipse or Netbeans running Ubuntu 12.04 64-bit.
What I tried:
1. Installing Eclipse, installing MDS AppLaud Phonegap Plugin (http://marketplace.eclipse.org/content/applaud-phonegap-android-jslintjshint#.Utf1JPiSTh8). This one actually installed at once, and it actually lets me create a new PhoneGap project in Eclipse, however, the I cannot select any SDK different than 4.4. (?!)
2. Installed NetBeans and after I tried to install phonegap and cordove through nodeJS it failed, again.
My question is:
Which one I should install and how to do it in Ubuntu, using either Eclipse of NetBeans?!
Edit:
OK guys, I just found out how to install nodeJS and PhoneGap on Ubuntu 12.04: http://paste2.org/1OnX6M6F . Still trying to integrate it in some IDE for the real thing, though!
If you want to basically start developing an app, I suggest this for PhoneGap:
These are the steps I used to install PhoneGap on Ubuntu. Take note, this is for PhoneGap version 2.8.1. Personally I was not able to get nodeJS to install the latest. If you need the latest to be installed, check around on google. Referencing This tutorial.
Step 1
Install Java 7 JDK
Step 2
Install ANT
Step 3
Download & Extract PG v2.8.1
Step 4
Download Android SDK
Step 5
Set up environment variables
Step 6
Create base project
./create location/to/put/project package_name project_name
Step 7
Import Project into Eclipse
File->New->Android->Android Project From Existing Code
Browse to where you placed the project and select it
Now you can start developing.
Reminder: This is the way to do it for v2.8.1 of PhoneGap. Different versions(especially 3.*) will be different (nodeJS)
Look at http://docs.phonegap.com. Read the "Overview chapter, then "Platform Guides" and "The Command-Line Interface". Follow the steps and in the end you should be able to build your app. It takes a while but it's worth it.
I havn't integrated cordova/phonegap in my IDE. I just created the app with the command line interface. In netbeans I created a HTML5 project and linked the app-root/www directory into this project. I'm programming with Netbeans and building and running the app with the command line interface. That's all.
In order to have some code completion, I have written an extra class (facade) which encapsulates the phonegap code. It just delegates its calls to the phonegap API. That is especially nice if the phonegap API changes as it only affects my code in that particular facade class.
The last thing I want to share: I found out that the build and run process with the command line interface is pretty slow. Executing cordova prepare android and then running the android project in Eclipse/ADT is a lot faster.
OK, to put it simple:
PhoneGap - The original project developed by volunteers
Cordova - The Apache's version of Phonegap, which has exactly the same documentation and functionality as the original PhoneGap but is integrated in NetBeans 7.4.

Phonegap 3 Custom plugin not working

I've build an application 6 month ago with phonegap 2.6.0. My application works great. I want to update my application with phonegap 3. I use the CLI to create the project, I copy and paste all the files in the new project. I had with the CLI the needed basic plugin (device information, camera...). this work.
But now, I've custom plugin that I've written that I need to put in my new project.
My question is: Do I need to rewrite all my custom plugin in order to get it working with phonegap3? Is there a way to use my "older" plugin in phonegap 3?
Thank you
Do I need to rewrite all my custom plugin in order to get it working
with phonegap3?
Yes, you will need to rewrite your plugin to use the new Cordova/phonegap. This is because a lot of things changed between how plugins interact with the main thread (on the native side) and how the JavaScript code is loaded into the page (now it uses require.js and AMD modules instead of just injecting the plugin code into window.plugins object.
Is there a way to use my "older" plugin in phonegap 3?
Unfortunately, no, there is no way that I know of to use old plugins.
Hopefully it won't take that much effort to rewrite your plugin. There isn't a plugin upgrade guide yet but it is something that is needed - as you do this upgrade, feel free to take notes about what you needed to do and donate those notes back to the community. This would be a tremendous help in starting the plugin upgrade guide.
I'd recommend going through these two docs:
Android Plugins
Plugin Development Guide
You could also probably look at the changelog for official Cordova plugins to see what they had to do between versions, but it might take some effort to determine the difference between bug fixes and updating the plugin code to work with new Cordova versions.

Categories

Resources