Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Tuesday, November 23, 2010

Ericsson Application Awards 2011

Ericsson Application Awards, An Android Competition has been announced, and now it is in stage 2. It is another opportunity for Android Developer to gain exposure within the telecom world, a chance to reach out to customers via Ericsson distribution channels and a chance to win €15,000 in prize money.


Read More……

Monday, December 1, 2008

Android SDK 1.0

Android SDK has been improved to the latest version 1.0 r2. You know posts before this, any code, created and compiled with previous version of SDK. Maybe they will not run well, or some of them need to be change for the current SDK.


The Code, I place in this site and in learncodes.googlepages.com was created with the previous version. so it need to be changed. I plan to make the code as it is created for historical, but for the new code will be based on new SDK. So, You, The Reader will still can access previous codes and new codes.

I hope you will make a great benefit from reading this site and learncodes.googlepages.com for increase your ability to code in Android.

Happy Coding! :)



Read More……

Friday, October 24, 2008

Android Market: An Alternative way to market our Android Program

Today i visit android developer blog and found article about Android Market. It is a place for user to browse applications have been developed with android and for now it is free to download them. For Developer, It is a chance to publish their work. And in the future They can distribute a paid application.


User that have Android Phone can rich their phone app by download it, and maybe try it before buy one.

This place would be an increased place day by day. As developer will make it as a chance to distribute their applications whether it is a paid application or a free application. For placing an application, Developer will be charge a fee $25 for first time only. Once registered, the application can be downloaded by user without further validation or approval.

I think $25 just a personal guarantee for developer's resposibility for their application, and they will have 70% of paid application bought by user.

Anyway, I see that Android Market is a chance for both developers and users.
Congrat to Android Market.


Read More……

Friday, February 22, 2008

Undroid: An Android Plugin for Netbeans

When do internet browsing, on java.sun.com, i found a link state that there is an android plugin for Netbeans. Its name is Undroid. Well, for you that using Netbeans as your Developer IDE, it is a great news. you can try this android plugin. If you interested just visit http://undroid.nolimit.cz/.


Read More……

Thursday, February 21, 2008

Android SDK m5-rc14 Released

New Android SDK released. There are some improvement, and changes. And some of my samples, i publish here and at learncodes.googlepages.com maybe have function that has been changed. But i think you the reader will be easily adopted.

Some of them, like there isn't onMotionEvent (MotionEvent ev) method but has been changed to OnTouchEvent(MotionEvent ev), there should be android:name on AndroidManifest.xml not id, but id, still can be use with warning.

So, hope you, the reader, will adopt it easily.


Read More……

Friday, February 8, 2008

ProgressBar: Android Simple Custom Component

It is interesting that we can create a customized component or in other word, we just say custom component in Android. From the documentation, it is permitted to build a custom component from any class / view class provided by android. Last night, i try to make a custom component, a progressbar component, just like a progress bar in VC++, BC++, or VB.

When browsing sample program ship with android SDK, there are some sample program providing with Android progress bar showing some screen. But it is not make me step backward, just want to know the feelling how can i create a custom component.

This ProgressBar simple custom component has been upload to my googlepages: Google Site you can study from that, and download the code to make your study easier.

On the reason to make you know what i say, just take a look at image below. Two image, one when the application run, and the second after simulate/stop.


First image


Second image



Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit My Google Site
Study Contact Database Application
and there is Android UI Design at there.



Read More……

Wednesday, February 6, 2008

Sample Android Database Application

For interacting with database, i have created a simple complete application using database in android. You can take a look at this application at my Contact Application in googlepages. You are free to download the sample code.

This application contains Contact Database, and some database manipulation. Fields included in the table are Contact Name, Address, Mobile Phone Number, and Home Phone Number. You can add, edit, and delete the contact.

I'm sure it will help you much to study database application inside android.
ok, have a nice try!

Good Luck !

Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit http://learncodes.googlepages.com
Study Contact Database Application
and there is Android UI Design at there.



Read More……

Tuesday, February 5, 2008

Changing TextView to receive user input programatically

TextView is the ancestor of EditText component. I've try to make TextView from XML design screen to receive input from user still is unsuccessful. But Programatically, i can change the TextView able to receive user input.

To do this, just create activity folder with activitycreator and modify the main activity class, say we have Sample Class below:

public class SampleTextView extends Activity
{
/** Called with the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
LayoutParams params = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
TextView v = new TextView(this);
v.setLayoutParams(params);
v.setInputMethod(TextInputMethod.getInstance());
v.setMovementMethod(ArrowKeyMovementMethod.getInstance());
v.setFocusable(true);
v.setText("TEST");
v.setBackgroundColor(0x88FFFF00);
setContentView(v, params);

}
}

Things you have to note is :
  1. Set the TextView to receive focus ( setFocusable )
  2. Set the Input Method to know how method will be used ( setInputMethod )
  3. Set the Movement Method to know how to handle cursor pointer ( setMovementMethod )


Compile and run the program, you can edit the content of TextView.
Good Luck !

Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit http://learncodes.googlepages.com/
and there is Android UI Design at there.


Read More……

Thursday, January 31, 2008

Opening New Screen in Android

An Android application, at most, contains more than one screen. But, how we can open a new screen after clicking a button, choosing a menu, or other? It is not too difficult to do in Android.

There are a few step to do, to open a new screen in android. You have to create an activity class, an xml layout, update AndroidManifest to know your second/third .. activity class, and put a code to call the new activity / screen.

An Activity class can be created with extending from Activity, ListActivity or other Activity class. Each Activity Class should have an xml layout as a view screen as a representation of the Activity Class.

Android Manifest should be updated to know the new activity / screen. so, when requested to show the new screen, it knows which class to execute.

At last you should put a piece of code to first screen, to show the new screen. Below is an example to open a new screen:

//screen1.java


package test.android;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.widget.Button;

public class Screen1 extends Activity
{
   public void onCreate(Bundle icicle)
   {
      super.onCreate(icicle);
      setContentView(R.layout.screen1);
      Button b = (Button) findViewById(R.id.btnClick);
      b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View arg0) {
         Intent i = new Intent(screen1.this, screen2.class);
         startActivity(i);
         }
      });
   }
}

//screen1.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="You are in the first Screen"
/>
<Button
   id ="@+id/btnClick"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Open New Screen"
/>

</LinearLayout>

//screen2.java


package test.android;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;

public class Screen2 extends Activity
{
   public void onCreate(Bundle icicle)
   {
      super.onCreate(icicle);
      setContentView(R.layout.screen2);
      Button b = (Button) findViewById(R.id.btnClick2);
      b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View arg0) {
         setResult(RESULT_OK);
         finish();
         }
      });
   }
}

//screen2.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="You are in the New Screen"
/>
<Button
   id ="@+id/btnClick2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Close"
/>

</LinearLayout>

//AndroidManifest.xml


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="test.android">
   <application android:icon="@drawable/icon">
      <activity class=".Screen1" android:label="Screen 1">
         <intent-filter>
         <action android:value="android.intent.action.MAIN" />
         <category android:value="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
      <activity class=".Screen2" android:label="Screen 2">
      </activity>
   </application>
</manifest>





ok, Have a nice try!

Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit http://learncodes.googlepages.com/
and there is Android UI Design at there.
You can download code almost the same as this at there too


Read More……

Run Android Application from Command Line

Sometime, we want to start the android application program from command line (Android Shell). Before, we usually clicking on the icon at application folder to run our program. So, there is an alternative way to run the program.

We use the Android Shell and issue am command to brought up the program. below is an example to do that.
1. Make sure that android emulator is running
2. Enter the shell with issuing command at command shell (prompt): adb shell
3. Issue am command. am command syntax is as follow :

am [start|instrument]
am start [-a <action>] [-d ] [-t <mime_type>]
[-c <category> [-c <category>] ...]
[-e <extra_key> <extra_value> [-e <extra_key> <extra_value> ...]
[-n <component>] [-D] [<uri>]
am instrument [-e <arg_name> <arg_value>] [-p <prof_file>]
[-w] <component>

for example we have android program with Manifest like below:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.iftitah.android.contact">
  <application android:icon="@drawable/icon">
   <activity class=".Contact" android:label="@string/app_name">
    <intent-filter>
    <action android:value="android.intent.action.MAIN" />
    <category android:value="android.intent.category.LAUNCHER" />
   </intent-filter>
  </activity>
 </application>
.
.
</manifest>

To run the code issue command like this (in one line):

am start -a android.intent.action.MAIN -n
com.iftitah.android.contact/com.iftitah.android.contact.Contact

ok, Have a nice try!

Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit http://learncodes.googlepages.com/
and there is Android UI Design at there.


Read More……

Friday, January 18, 2008

Android Database

Database is important thing in programming. Many of our code always use data to be processed and saved. Just like any other programming environtment, Android support database programming too. You can use default database supported by android, SQLiteDatabase.

Database in SQLiteDatabase can contains more than one table, assume that we have one database PERSONALDB, and have one table BIODATA. The structure of BIODATA is:

_id integer
code string
name string
gender string

_id is for key increment,
code, name, and gender is for description of person.

When program called in the first time, we have to make sure that the database and table opened if it is exist. if not, than we have to create the database and tabel. As an example from Android notepad sample, here the class PersonDbHelper for manipulating table Biodata.

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class PersonDbHelper {
    class Row extends Object {
        public long _Id;
        public String code;
        public String name;
        public String gender;
    }

    private static final String DATABASE_CREATE =
        "create table BIODATA(_id integer primary key autoincrement, "
            + "code text not null,"
            + "name text not null"
            +");";

    private static final String DATABASE_NAME = "PERSONALDB";

    private static final String DATABASE_TABLE = "BIODATA";

    private static final int DATABASE_VERSION = 1;

    private SQLiteDatabase db;

    public PersonDbHelper(Context ctx) {
        try {
            db = ctx.openDatabase(DATABASE_NAME, null);
        } catch (FileNotFoundException e) {
            try {
                db =
                    ctx.createDatabase(DATABASE_NAME, DATABASE_VERSION, 0,
                        null);
                db.execSQL(DATABASE_CREATE);
            } catch (FileNotFoundException e1) {
                db = null;
            }
        }
    }

    public void close() {
        db.close();
    }

    public void createRow(String code, String name) {
        ContentValues initialValues = new ContentValues();
        initialValues.put("code", code);
        initialValues.put("name", name);
        db.insert(DATABASE_TABLE, null, initialValues);
    }

    public void deleteRow(long rowId) {
        db.delete(DATABASE_TABLE, "_id=" + rowId, null);
    }

    public List<Row> fetchAllRows() {
        ArrayList<Row> ret = new ArrayList<Row>();
        try {
            Cursor c =
                db.query(DATABASE_TABLE, new String[] {
                    "_id", "code", "name"}, null, null, null, null, null);
            int numRows = c.count();
            c.first();
            for (int i = 0; i < numRows; ++i) {
                Row row = new Row();
                row._Id = c.getLong(0);
                row.code = c.getString(1);
                row.name = c.getString(2);
                ret.add(row);
                c.next();
            }
        } catch (SQLException e) {
            Log.e("Exception on query", e.toString());
        }
        return ret;
    }

    public Row fetchRow(long rowId) {
        Row row = new Row();
        Cursor c =
            db.query(true, DATABASE_TABLE, new String[] {
                "_id", "code", "name"}, "_id=" + rowId, null, null,
                null, null);
        if (c.count() > 0) {
            c.first();
            row._Id = c.getLong(0);
            row.code = c.getString(1);
            row.name = c.getString(2);
            return row;
        } else {
            row.rowId = -1;
            row.code = row.name= null;
        }
        return row;
    }

    public void updateRow(long rowId, String code, String name) {
        ContentValues args = new ContentValues();
        args.put("code", code);
        args.put("name", name);
        db.update(DATABASE_TABLE, args, "_id=" + rowId, null);
    }
    public Cursor GetAllRows() {
        try {
            return db.query(DATABASE_TABLE, new String[] {
                    "_id", "code", "name"}, null, null, null, null, null);
        } catch (SQLException e) {
            Log.e("Exception on query", e.toString());
            return null;
        }
    }
}

in Method onCreate Activity you just put single command below to initialize the database :
...
Db = new PersonDbHelper(this);
...

it will try opening PersonalDB first, if it is not exist, than it will create the database. in this PersonDbHelper class, you have method for inserting, deleting, updating, querying table.

Ok, have a nice try

Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit http://learncodes.googlepages.com/
and there is Android UI Design at there.


Read More……

Tuesday, January 15, 2008

Layouting Component Choices

Component Arrangement on Android is simple and we have more than one way to make the same design screen. we can use RelativeLayout, LinearLayout, or other layout. And we can combine two or more layout into one design screen.

For example, we want to desain screen as the image below:


The design screen can be expressed as below:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView id="@+id/objLbl1"
android:layout_width="80sp"
android:layout_height="24sp"
android:text="Code"
/>
<EditText id="@+id/objTxt1"
android:layout_width="134sp"
android:layout_height="24sp"
android:layout_alignTop="@id/objLbl1"
android:layout_toRight="@id/objLbl1"
android:text="Edit 1"
android:singleLine="True"
/>
<TextView id="@+id/objLbl2"
android:layout_width="80sp"
android:layout_height="24sp"
android:layout_below="@id/objTxt1"
android:text="Name"
/>
<EditText id="@+id/objTxt2"
android:layout_width="134sp"
android:layout_height="24sp"
android:layout_alignTop="@id/objLbl2"
android:layout_below="@id/objTxt1"
android:layout_toRight="@id/objLbl1"
android:text="Edit 2"
android:singleLine="True"
/>
<Button id="@+id/objBtn1"
android:layout_width="80sp"
android:layout_height="24sp"
android:layout_below="@id/objTxt2"
android:text="Save"
/>
</RelativeLayout>

Or, your can replace with xml below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView id="@+id/objLbl1"
android:layout_width="80sp"
android:layout_height="24sp"
android:text="Code"
/>
<EditText id="@+id/objTxt1"
android:layout_width="134sp"
android:layout_height="24sp"
android:text="Edit 1"
android:singleLine="True"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView id="@+id/objLbl2"
android:layout_width="80sp"
android:layout_height="24sp"
android:layout_below="@id/objTxt1"
android:text="Name"
/>
<EditText id="@+id/objTxt2"
android:layout_width="134sp"
android:layout_height="24sp"
android:text="Edit 2"
android:singleLine="True"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>

<Button id="@+id/objBtn1"
android:layout_width="80sp"
android:layout_height="24sp"
android:text="Save"
/>
</LinearLayout>
</LinearLayout>

Ok, have a nice try!

Do you want to learn more ?
Learning with sample code ?
Learning by Doing ?
Just Visit http://learncodes.googlepages.com/
and there is Android UI Design at there.


Read More……

Monday, January 14, 2008

Viewing Android Debugging Log

When our application is installed on android emulator, we run it and expect it will running successfully. But, sometimes it is unsuccessfully, an error message appears, sometimes, likely it is not from our application, so how to know which part of our codes is currently throwing the error..

An alternative way is to watch the log produced by the emulator. Just run the emulator, wait until completed, then from shell, issue command:

adb logcat

The log will be show up at a new windows, and you can watch which part of your codes currently throwing error.











ok, have a nice try!


Read More……

Accessing Android Shell

Frequently, we want to know where the code placed inside android. we can know it with entering the Android Emulator shell. Just run the Emulator and wait it runs completely, issue command to access shell, then we will be inside the Emulator shell.

Here the command to access Shell :

adb shell

then we will promptly with
#

it is linux shell command, and we can issue command just like in Linux environtment, with some limitation.

Application installed in emulator will reside at /data/app/ directory, and database(s) create by the app will reside at /data/data/<package name>/databases/

Ok, have a nice try!


Read More……

Resize Android EditText in XML

Someday, we want to set size Android Component in our application. We have many ways to set and reset the size of component. In this example we deal with Android EditText.

The Size of Component in Android can be set in XML with providing property android:layout_width and android:layout_height with a value followed by unit. For example we want to set EditText with 200sp width and 24sp height, the declaration is as follow:

<EditText id="@+id/Text1"
android:layout_width="200sp"
android:layout_height="24sp"
android:text="Text1"
android:singleLine="True"
/>

For detail information on unit like "sp", "pt", you can browse at Android Documentation or in topic Creating User Interface

Ok, Good Luck!


Read More……

Saturday, January 12, 2008

SMS Emulation on Android

When we are trying to test SMS based program on Android, we have to simulate receiving SMS. Fortunately, with new SDK, we can simulate the SMS come to Emulator. We have just to connect to emulator using telnet and there we can emulate the SMS. Below step by step to emulate the SMS:
  • Start the emulator, you free to give the option, For example just type emulator on shell prompt
  • Open a new shell and type :

    adb devices

    to know the port emulator used. The console of the first emulator instance running on a given machine uses 5554 port, The command above just to make sure which port the instance used.
  • Connect to the console using telnet command like:
    telnet localhost 5554
  • After you have come to the shell you can emulate sms with command:

    sms send <phonesender> <text message>
Ok, Good luck with your try, and Hope, One of Use will win the Android Google Challenge!


Read More……

Monday, January 7, 2008

Android User Interface Designer (2)

Android User Interface Designer that i 've write before has been released. You can download and try it. This code can be download at SourceForge.Net and can be download and Files.
Just Try it and enjoy it!


Read More……

Wednesday, January 2, 2008

Creating User interface

User interface in Android Platform just like other Java based user interface in common. We can create User Interface from the scratch with Java code, or Using XML that come with Android. Everytime we create Android Project whether from command line using ActivityCreator or Using Android Plugins on Eclipse we have some directory result. One of them is res directory. Res directory contains layout and value subdirectory. The XML that govern the User Interface located in these subdirectories at most.

Some Definition about the layout we place at layout subdirectory, the value refers in the layout placed in value subdirectory. let's start with the main.xml located in layout directory. Main.xml contains main definition of layout. below sample of main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView id="@+id/objLbl1"
android:layout_width="134sp"
android:layout_height="80sp"
android:text="Label 1"
/>
<EditText id="@+id/objTxt1"
android:layout_width="134sp"
android:layout_height="134sp"
android:layout_alignTop="@id/objLbl1"
android:layout_toRight="@id/objLbl1"
android:text=""
/>
<Button id="@+id/objBtn1"
android:layout_width="134sp"
android:layout_height="24sp"
android:layout_below="@id/objTxt1"
android:layout_toRight="@id/objLbl1"
android:text="Btn 1"
/>
</RelativeLayout>

RelativeLayout is a layout with each object inside is placed relative to others. Maybe below, right, align top, align bottom to other object. There are many Layout but we study this first. There are 3 attributes at least, to define this layout, xmlns:android, android:layout_width and android:layout_height.

xmlns:android is for identification that this xml is used for android, not for other function, android:layout_width and android:layout_height is to specify the dimension. it can be fill_parent, wrap_content, or just spesify the dimension with number followed by unit of measurement.

Unit of measurement supported by android (from the documentation) can be :

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ration of dp-to-pixel will change with the screen density, but not necessarily directly; instead the ratio is selected is something that is close to the screen.

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

There are many object that can be created. but we focus on Label, EditText, And Button, because these three objects is used frequently.

Label is declared with tag <TextView />. Some attributes can be set to this object, but we can just used id, the dimension, text attribute, and relative position to others like align with other, right from other, and below from other. Id is used to identify this label. In this example, Label is placed first, so others will refer it with its id

EditText is declared with tag <EditText />. Attributes used in this example is just like label but with position relative to the label. Its relative position is to the right from label.

Button is declared with tag <Button />. Attributes used in this example is just like edittext but with position relative to edittext and label. Its relative position is below from the edittext and right after label.


Read More……

Thursday, December 13, 2007

Android and Eclipse


We can use the power of Eclipse IDE to code in Android Platform. What we need is just Android Plugins for Eclipse and Eclipse itself. Below, step by step to use eclipse and Android plugin:

  1. Download Eclipse europe from this Eclipse Download Site (www.eclipse.org/downloads)
  2. Install Eclipse, for windows version you just extract the zip file into destination folders.
  3. Download Androiod plugins for eclipse
  4. Run Eclipse IDE
  5. Choose Menu : Help->Software Updates->Find and Install
  6. Choose "Search for new features to install" radiobutton and click next button
  7. Press "New Local Site" button and specify the directory where Android Plugin has been extracted.
  8. Press OK button
  9. if it is found than "Sites to include search" will contains "Android/android_eclipse_plugin_adt.x.x.x"
  10. Press "Finish" button
  11. The Series of dialogs to install the plugins will show up, just press next button and agree with the agreement (if you have read the agreement and want to agree) and press finish at last. Eclipse need to restart when this instalation has finish.
  12. When we are asked the Android SDK directory, just choose Windows->Preference, and choose the Android preference, point to Android SDK Folder just before the tools directory under the Folder.
  13. The Eclipse ready to use for Android Programming.


Good Luck.



Read More……

Wednesday, December 12, 2007

Creating HelloWorld on Android

Always, when we start learning a new language, we start with a helloWorld program. A HelloWorld program just contains a simple code to say A hello within the system/environtment. So, We start our Android Learning with creating A helloWorld Program.

Below a step by step creating a helloWorld Program:
  1. Open up a Command Prompt window, go to the directory prepared for this (assume trial) and create workspace for HelloWord, code below:

    d:\trial>activityCreator --out HelloWorld com.mylearn.HelloWorld

    This command will create a directory under HelloWorld under trial, the HelloWorld directory contains some files and directory :

    src\ contains source code for HelloWord
    bin\ contains binary/intermediate code will be installed on the
    device/emulator, initialize empty first
    res\ contains resource file
    AndroidManifest.xml manifest
    build.xml information for building the program

  2. change to HelloWorld directory, and compile the program using ant

    d:\trial\helloword\>ant

  3. Start Android Emulator, you can issue the command to start Android Emulator from command line using command like this :

    d:\trial\helloworld\>start emulator.exe

    Android Emulator show up, initialize everything, and ready to use.

  4. Transfer the HelloWorld Program that has been compiled using adb tools command:

    d:\trial\helloworld\>adb install bin\helloworld.apk

    if the process running successfully, than we can access helloworld program from the emulator.

  5. Go to Application folder on the emulator, and there exist helloworld icon. click the icon, and the HelloWorld Program will show up.



Read More……