How To Create Application For Android Using The Android Development Framework

Initially we must set up our development environment, you must install the latest version of the SDK and ADT plugin on Eclipse. To do all this initial setup read the following tutorial: Learn how to set up a development environment for Android and back here when you have completed the setting.
How To Create Application For Android

Step 1 How To Create Application For Android

After configuring the development environment for Android, let's create an AVD, and what an AVD you ask. Well, to be able to run the applications created, an Android emulator is required. The ADL is an Android Virtual Device, which allows emulate an Android system.

To create an AVD, we will use the Android SDK tools.
Open an MS-DOS command window, and goes to the SDK tools directory and run the following command:

android list targets

This command will list the targets available for Android, as you can see, you are related to the version of Android. Since the aim is to create an application to version 2.2 of Android, let's run the following command with the id 12 for the target:

android create avd -target 12 -name my_avd_22


Running the command will ask if they want to create a custom hardware PROFILE carries on enter to select default option ("no").

We then created an AVD named "my_avd_22", which uses the plantaforma 2.2.

Step 2

Once created our AVD, the next step is to create a project for Android in Eclipse.
  • Opens Eclipse
  • Go to the menu, File> New> Project
  • Select the wizard for Android Project.


  • Fills in the details of the project according to the picture and then click Finish.

Your project is now ready. Opens the file, OlaMundo.Java should be like this:


com.ninja42 package;
import android.app.Activity;
import android.os.Bundle;
public class helloworld extends Activity {
    / ** Called When the activity is first created. * /
    Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.main);
    }
Notice that is class is based on the Activity class. An Activity is a single entity, which is used to perform actions. An application may have different "activities", but the user may interact with only one at a time.

The method onCreate () is called by the Android system when the "Activity" begins. It is here that should be made ​​the boots and the Setup UI.

Step 3

Let us now make some changes to the code base. The code has added the comment ahead of Added.
com.maistutoriais package;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView; // Added
public class helloworld extends Activity {
   / ** Called When the activity is first created. * /
   Override
   public void onCreate (Bundle savedInstanceState) {
       super.onCreate (savedInstanceState);
       TextView tv = new TextView (this); // Added
       tv.setText ("Hello, World!"); // Added
       setContentView (tv);
   }
}
An Android interface is composed of hierarchies of objects called Views. A View is an object drawable used as an element in your layout as well as a button, image or label. Each of these objects is a subclass of View and the subclass that contains the text is a TextView.

With our changes, we create a TextView with the constructor that takes an Android Context. A Context is a handle to the system, which provides services such as resources, access to databases and preferences. The Activity class inherits from Context, and how our helloworld is a subclass of Activity, is also a Context. So we can spend this as a reference for the Context in TextView.

After we set the text using the setTex (CharSequence) setText ().

Finally, we pass the TextView to setContentView (), so we can set it to display the Activity UI. If your Activity does not call this method, no UI and presented the system will not be set only an empty screen!

Step 4

Finally, since just need to run our application. The Eclipse make this very simple. Go to the menu Run > Run in the window select an "Android Application" and click OK.

The ADT plugin in Ecplise will create a configuration to launch the Android emulator automatically. Once the emulator is started (it may take 1 or 2 minutes), your application will appear!


And ready, so comes to an end another tutorial! I hope you have completed successfully tutorial, if you have any questions or difficulty leaving your comment.

Sign up here with your email address to receive updates from this blog in your inbox.

1 Response to "How To Create Application For Android Using The Android Development Framework"

  1. Coin Casino: Play For Free With $200 No Deposit Bonus
    Coin Casino is a leading Bitcoin gambling site, 메리트 카지노 주소 offering 인카지노 a range febcasino of great new games and some fantastic offers. Join now and enjoy the best online

    BalasHapus