Android phonegap access jarfile - javascript

I'm just getting started using phonegap. I have some implemented libraries (jars) and I want to access them through javascript. I've been looking for an example to do this but I didn't find any. If you know any link or tutorial that would be great.

Here is a tutorial that shows how to use a Barcode Scanner library with a plugin for a PhoneGap app. (Note that it is written for PhoneGap 1.4.1, so you'd have to make appropriate namespace changes if you use a more recent PhoneGap/Cordova version.)

Related

How does Apache Cordova and ionic framework interact native-ly?

I'm trying to find out how does Apache Cordova & Ionic Framework work?
I searched all over the internet and all I get is,
it is a wrapper around html/css/js and it uses the native web view to interact with native feature. But, you still deploy the native-ly. (That means .apk for Android, e.g.)
But, what I'm interested in is
Is Apache Cordova and Ionic Framework entirely written in javascript?
How do they interact with native mobile platform?
Does cordova/ionic get bundled with .apk file to mediate between the native web view and source code?
I believe what I'm interested in bit of low level detail.
If anybody could shed some light or point me to the resource (which I couldn't find) , it'd be great.
Thanks.
Apache Cordova provides a basic native app responsible for:
Displaying a Webview (UIWebkit by default for iOS, but you can switch to WKWebkit using a plugin. For Android, the "android browser" webview is used up to Android 4.4. From Android 5 (API 21), the webview is basically Chrome for Android).
Allowing the JavaScript running into this webview to "call" (execute) native code thanks to Cordova plugins. This is possible because system Webviews can interact with native code.
Ionic Framework (v1) is made of HTML, JavaScript and CSS (v2 is developed in TypeScript, which is a typed superset of JavaScript). The version 1 relies on AngularJS as a frontend JavaScript framework and helps developers writing "native-like" webapps by providing features like Gestures management, Infinite scrolling, Layouts (Menu, Tabs, Lists...), etc. The version 2 relies on Angular 2 and provides additional components (Date picker, Split panel...) and features (Ionic Native, a JavaScript API which tends to "standardize" the way you use Cordova plugins).
Ionic can be used without Cordova, if you simply want to create a web app (this is still HTML, JavaScript, and CSS). Cordova allows you to put this web app into a native shell. When an hybrid app (Cordova, the plugins you installed, and your web app) is bundled into an .ipa or an .apk, the html/javascript/css codes are moved into a specific folder, where Cordova expects to find an index.html (by default) to load in the Webview.
PS: My english is not perfect but I'd be glad to give more details if a point is not clear.
EDIT:
Please can you answer my specific questions in my post?
Sure!
Apache Cordova is made of JavaScript and Native code. See projects like cordova-android (JavaScript + Java), cordova-ios (JavaScript + Objective-C). Each mobile operating system has a dedicated "platform". When you start a new Cordova project, most of the time, the first operation you do is cordova platform add <platform> (iOS, Android...). These are the codes being loaded. Ionic Framework is a "pure-web" framework, made of HTML, JavaScript and CSS.
Apache Cordova interacts with native mobile platform as any native app: using the system APIs. The webview can interact with both your web app (of course) and the native code, thanks to platform-specific "bridges" (the native code embedded in cordova-android, cordova-ios, cordova-windows, allows that). You have to write a plugin in order to call native code from your JavaScript. For Android, it consists in extending the CordovaPlugin class and overriding the method execute (for instance: cordova-plugin-splashscreen).
The .apk (android) or .ipa (iOS) generated by cordova build (if you're using the cordova-cli) gathers together both the native shell (cordova-android for Android, cordova-ios for iOS) and your webapp. At startup, the main activity/view of Cordova is instantiated, loads the webview, which itself loads your webapp.

Cordova navigator.device issue

I am using phonegap to build android application using JavaScript and HTML. I am trying to include audio and video features in my application. It is giving error capture of undefined for following code. Can anybody suggest me better way to handle audio and video feature?
navigator.device.capture.captureVideo(captureSuccess, captureError);
Which version of phonegap/cordova are you using for development?
You need to manually add the plugin for phonegap/cordova 3.+ onward.
Camera plugin link here
To manually add plugin.
To add the camera plugin use the below command
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git

Is it possible to implement HTML5 (I plan to use WebRTC)as a WebView within a native Android application?

I am thinking about developing a android application to make a WebRTC call. Unfortunately the native WebView in android does not support such feature. I tried XDK with CrossWalk and it works with WebRTC well, but the problem is that it is a pure HTML, Javascript application. I suppose the capability of HTML5 application in android would be a problem? (Notification, service, communication with database). So what I am thinking is that maybe I can build a hybrid application with the framework of a native application and a WebView with it? Thanks in advance, that would help me a lot.
Yes, it is possible. I build this HTML5 , https://www.noupei.com/. Its fully HTML5, build using jQuery and jQuery Mobile. One of my college easily transpose it using a webview for android, https://play.google.com/store/apps/details?id=com.knowledge7.android.noupei
BUT
It is also possible to completely develop your whole application using HTML5, and then package it with something like phonegap, the advantage you have is that using something like phonegap allows you to access the native features of the Android Device.
For HTML5 technologies like Bootstrap that allows you to make very good mobile interfaces are fully mobile responsive. It is possible to make very beautiful and attractive interfaces as well as you also have very good javascript frameworks like AngularJS.

Phonegap plugins not working

Phonegap plugins not working in Phonegap cordova-1.5.0 in iPhone. I added the plugin for date picker and one anohe plugin for making phonecall.
I used the plugins from
https://github.com/phonegap/phonegap-plugins/tree/master/iPhone.
Any one have any idea about this issue??
I just added the external JS file and called it directly. Do I need to make any changes in the plist or somewhere else. Can anyone tell me the steps to use the Phonegap Plugin in iPhone.?
Make sure that you are using the PhoneGap version that is compatible with the plugin structure (there were changes around 2.0, and Version 1.5 is pretty old). For the latest architecture, check here for details:
http://docs.phonegap.com/en/2.7.0/guide_plugin-development_index.md.html#Plugin%20Development%20Guide
For the older plugin architecture, check here:
http://www.adobe.com/devnet/html5/articles/extending-phonegap-with-native-plugins-for-ios.html
Depending on the version, yes, you may need to edit the .plist files in your Xcode project. You also have to add the native files to the Xcode project, not just the JavaScript.

Writing apps for Apple platforms with Javascript

Does Apple allow iOS and Mac apps to use Javascript? Can someone give me examples of how to use it and the advantages and disadvantages?
If you're looking for a less techy solution, you could also use AppFurnace ( http://www.appfurnace.com ) to create JavaScript & HTML5 apps, packaged as native apps for iPhone and Android. We use PhoneGap (mentioned above), with an added drag-and-drop interface, enabling you to make your own apps.
You can use phonegap as a javascript, html and css wrapper in your ios app if you want to create a native app using html and javascript.
There's NimbleKit which allows you to make native apps using HTML and Javascript. Otherwise you can use a UIWebview which you can execute Javascript in. Look at the UIWebView documentation for more info.
There are tools to code your app in javascript and compile it into native code.
But if you want your app to load javascript code at runtime and run it, then see this for more details.

Categories

Resources