Get Started with PhoneGap and App42 JS SDK

PhoneGap gives you the power to write your App in JavaScript language and build it for native platforms like Android/iOS/Windows/BlackBerry etc. This saves a lot of time and effort for an App Developer as he won’t have to write UI and Business Logic for porting it to different platforms. If your HTML 5 App is build using App42 Backend, you can also build your App for different platforms like Android and iOS using PhoneGap. App42 JavaScript APIs are compatible to work with PhoneGap.

Below is the step by step guide to build App42 “To-Do” Sample Application for Android device using PhoneGap.

phoneg Get Started with PhoneGap and App42 JS SDK

Download and Initialize App42 Java Script To-Do List Sample:

1. Register with App42 platform.
2. Go to dashboard and click on the Create App button.
3. Fill all the mandatory fields and and check the ACL = true to get your APIKey and SecretKey.
4. Download App42 Java Script sample app and unzip it on your machine .
5. Edit index.html file and put your APIKey and SecretKey (which were received in step#2 & #3) as shown below:

1
App42.initialize("Your APIKey","Your SecretKey");

Prepare Android Setup

  1. Download and Install Android SDK. For details please see http://developer.android.com/sdk/index.html
  2. Download PhoneGap Binaries from https://github.com/phonegap/phonegap/archive/2.9.0.zip

Build Sample for Android:

  1. Create new android project (Android 2.3.3) in eclipse.
  2. Create folder www in assets and add App42 To-Do Sample (Content of Root Folder) into it.
  3. Now add jar file cordova-2.9.0.jar to libs folder (It is available in PhoneGap binary distribution downloaded in above step)
  4. Also add cordova-2.9.0.js(Available inside PhoneGap disribution) in www folder.
  5. Import cordova-2.9.0.js into your project i.e in index.html as shown below
  6. script type="text/javascript" src="cordova-2.9.0.js"
  7. Open MainActivity.java file and add an import statement for org.apache.cordova.DroidGap and extend it with the same.
1
2
import org.apache.cordova.DroidGap;
public class MainActivity extends DroidGap
  1. Modify onCreate method to load index.html as shown below.
1
2
3
4
5
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  super.loadUrl("file:///android_asset/www/index.html");
}
  1. Open the AndroidManifest.xml and add a child element to the application node as shown below
1
2
3
4
5
6
<activity
    android:name="org.apache.cordova.DroidGap" 
    android:label="@string/app_name" 
    android:configChanges="orientation|keyboardHidden"> 
    <intent-filter></intent-filter> 
</activity>
  1. Add child uses-permission node to the manifest node as shown below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:resizeable="true"
    android:anyDensity="true"
    />
  1. To run your android application right click on your project and run as Android Application.
  2. This will create apk file that you can run in emulator or device.
PhoneGap1 Get Started with PhoneGap and App42 JS SDK
PhoneGap2 Get Started with PhoneGap and App42 JS SDK
If you have any questions or need further assistance to integrate this in your App, please feel free to write us at support@shephertz.com
twitter Get Started with PhoneGap and App42 JS SDKfacebook Get Started with PhoneGap and App42 JS SDKgoogle Get Started with PhoneGap and App42 JS SDKlinkedin Get Started with PhoneGap and App42 JS SDKpinterest Get Started with PhoneGap and App42 JS SDKreddit Get Started with PhoneGap and App42 JS SDKstumbleupon Get Started with PhoneGap and App42 JS SDKtumblr Get Started with PhoneGap and App42 JS SDK

Leave a Reply

Your email address will not be published. Required fields are marked *


× 3 = twenty four

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>