Tips and Tricks in a world of Mix

Let’s assume that we’ve installed all the needed software as described in :

http://wiki.phonegap.com/w/page/16494774/Getting%20started%20with%20Android%20PhoneGap%20in%20Eclipse

 

Now we open the Eclipse :

image

File –> New –> Android Project

now will add the project definitions

image

When you choose Android 2.2 automatically Min SDK Version defined as 8

Package should be with two parts – package name and project name

Next –> Finish

 

Open new folders libs and assets\www

image

 

 

Go to phonegap source  and get the phonegap.0.9.6 jar and js files.

image

jar goes to libs

js goes to assets\www

image

 

Now we’ll add the phonegap library to the project so:

Right click on jar file –> build path –> add to build path

image

Afterwards you can see the referenced library added to the solution :

 

image

Now we can reference it in code .

Go to src –> Pack.MyTest –> MyTestActivity.java –>

Add import and change extending :

Original Source:

package Pack.MyTest;

import android.app.Activity;
import android.os.Bundle;

public class MyTestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

 

Changed adding phonegap and extending from Droid and add the start page :

package Pack.MyTest;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.*;
import com.phonegap.*;

public class MyTestActivity extends DroidGap {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        ///add the start page
        super.loadUrl("file:///android_asset/www/index.html");
        setContentView(R.layout.main);
    }
}

Add to assets\www index.html start page as promissed :

image

(put the reference to phonegap.js inside)

 

Define the properties of the runner AVD :

image

image

Define what project you want to run :

image

Go to Right click MyTest –> Run as –> Android Application

 

image

 

Our Android application :

image

Go to your VS 2010 and open WebSite

image

 

Find your workspace for eclipse –> Open :

image

Work with VS – > JQM

image

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: