Posts

Showing posts with the label Phonegap

PhoneGap: Getting Data from a Server

Well your application would be pretty useless if you couldn't get data from a remote server now wouldn't it? Luckily since your PhoneGap application is running off of the file:// protocol it isn't limited by the same origin policy . This means we can request data using XmlHttpRequest from any domain. I'm going to give you an example of searching for all tweets that mention PhoneGap that demonstrates this ability without the use of any extra JavaScript library like jQuery or Dojo. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ...

Working with JSON & PhoneGap Application

I Love to use JSON objects especially when working with PhoneGap Applications. I find it very comforting while transferring data from client to server and vice versa. I will explain through a simple example how I use JSON to ease the client-server data transmission. Example will be, a client asking for the details of the Employee working in the Accounts department. Basic Algo for the Example will be as follows, Client will make an Ajax request, asking for the Details of Employees working in an Accounts Department. On receiving the Request, Server will fetch all the details of the Employees working in Accounts form Database, convert these details to an Json Objects and send back to the Client. Client on Receiving the Response from the server will parse the JSON objects and convert the data in local JS variables and render the data at client side, i.e. in a table grid etc. as per requirements.  At the client Side, Include the following js files, json2.js...

Getting an Access of Android Java Code to a PhoneGap JavaScript.

PhoneGap Provides a standard set of functions available in PhoneGap docs to access the internal Device Details like the list of the phone numbers, access to camera etc. Apart from this standard functions, if our requirements extends then these available functions, then we need to create our own custom logical functions which access the internal device hardware details like 'imei' number etc or to apply some custom logic or validate the data and then make it available to PhoneGap, then this article helps to do the same. Though PhoneGap provides the 'imei' number through the standard function 'device.uuid' but in Android 2.1, it is still an issue. For such cases we need to take the help of the Native Android Java Code and then make it accessible to PhoneGap, here is how we will be doing the same. Following example is of getting the device's 'imei' number through the Android's TelephonyManager class and then make it available to Pho...

Extending HTML5 Mobile Apps with C++ in MoSync

Invoke C++ Code from JavaScript The following example code is based on the HTML5/JS/C++ Hybrid Project Template . This template illustrates how to invoke custom C++ code from JavaScript. The UI has buttons for making the device vibrate and beep. To create a project based on this template, launch MoSync SDK, and create an app in the Eclipse-based IDE, using the HTML5/JS/C++ Hybrid Project template. Then you will get the source code discussed below. The template app uses the Wormhole C++ library (classes HybridMoblet and MessageStream) and the JavaScript libraries included in the file wormhole.js (all included with the application template). Sending String Messages It is good to know that two message formats are supported by Wormhole: JSON messages and String stream messages. The example we discuss here uses String streams. String streams are a performant way of sending messages from JavaScript to C++. This method is generally faster than JSON messages (on some platfor...

Getting Started PhoneGap with Android

Image
This guide describes how to set up your development environment for Cordova and run a sample application. Note that Cordova used to be called PhoneGap, so some of the sites still use the old PhoneGap name. 1. Requirements Eclipse 3.4+ 2. Install SDK + Cordova Download and install Eclipse Classic Download and install Android SDK Download and install ADT Plugin Download the latest copy of [ PhoneGap and extract its contents. We will be working with the Android directory. 3. Setup New Project Launch Eclipse, and select menu item New > Android Project . Fill out the three panels of the New Android Project wizard shown below. In the root directory of your project, create two new directories: /libs assets/www Copy cordova-1.8.0.js from your Cordova download earlier to assets/www Copy cordova-1.8.0.jar from your Cordova download earlier to /libs Copy xml folder from your Cordova download earlier to /res Verify that cordova-1.8.0.jar...

PhoneGap with native plugins for Android

Image
Requirements Prerequisite knowledge A good understanding of the fundamentals of PhoneGap and programming in Objective-C is required to make the most of this article. User level Intermediate Sample files myfirstphonegapplugin_a.zip This article examines native plugins for PhoneGap (also known as Apache Cordova) applications in Eclipse, targeting Android devices. If you are just starting out with PhoneGap or if you need to review the fundamentals of PhoneGap, read Getting started with PhoneGap in Eclipse for Android before continuing. The terms Cordova and PhoneGap are used interchangeably within this article to refer to the same open source application platform that lets you create natively-installed mobile applications using HTML and JavaScript. The PhoneGap codebase moved to open source at Apache Software Foundation under the name Cordova. Adobe is...