Showing posts with label application. Show all posts
Showing posts with label application. Show all posts

Directory Structure of Android Application

| 0 comments |
When you create new android project from eclipse editor you found that there are lots of directories created for android application lets us understand all these directory.

Let us start from the top directory the top most directory is src directory.
SRC Directory
The src Directory contains the java files inside package.
gen Directory
The gen directory contains folder that are generated for us by the toolset. one of the best thing you will find in gen directory is R.java file. R.java file update automatically by the system whenever you add or remove the design object or anything. in straight forward way whatever you add or remove from your project will be update in R.java file.
Android 1.5 or X.X
This folder is associate with the  SDK version  this is the thing that we have to configure when we create new project of android application.

assets
the assets folder provides repository for your resource which are using by your android application. for eg if your android application has sound effect then you can put those sound files in this folder but you cant put image files in this folder because we have another folder for images like stuff.
bin
Every program gets compiled and generate binary files same way android program also gets compiled and generate binary files. android bin folder contains the compiled binary files.
res
the res folder doesnt contain any files but it is one of the most important directory in android application. let us see what kind of directory res folder has.
res/drawable
Drawable folder contains images. there are three kind of screen density. you can specify same three images for different screen density. for eg res/drawable-hdpi contains all your image resources for high-resolution devices.   you dont need to specify which density images to pick when but operating system will choose it at run time.
res/layout 
the layout folder is where you put your main.xml file. all design resources are stored in this folder.
res/values
values folder contains string resource. mostly its in key value pair. some common file is strings.xml
AndroidManifest.xml: 
The manifest file is responsible for providing essential information to the operating system about a   particular application. for e.g. used to specify the default activity to launch.


Android Apk
Read More..

Execution Flow of Android Application

| 0 comments |
As a Beginner You need to know the execution flow of your android application. to understand the basic execution flow of android  we are  considering the hello world example.

When you create the android project in eclipse lots of folder are created such as "src" ,"gen" , "Android 1.5"  , "assets" and "res" folder.
To understand android flow we are starting with the "res" folder. In "res" folder there is a file called "AndroidManifest.xml".
These below is the content of AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest
      package="com.example"
      android_versionCode="1"
      android_versionName="1.0">
    <uses-sdk android_minSdkVersion="3" />
    <application android_icon="@drawable/icon" android_label="@string/app_name">
        <activity android_name=".HelloWorldDemo"
                  android_label="@string/app_name">
            <intent-filter>
                <action android_name="android.intent.action.MAIN" />
                <category android_name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
      
    </application>
</manifest>

In the Above Xml code we have an activity called "HelloWordDemo" listed in activity tag this activity will be launched first. if you have multiple activity in your android application you must have to register all your activity in AndroidManifest.xml file.
you can specify your child activity by just <activity android_name=".xyz"></activity> adding as many tag as many activity you have in your android application. Make sure you specify "." (dot) before each activity.
Activity name ".HelloWorldDemo" will call HelloWorldDemo.java file.
package com.example;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorldDemo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
When HelloWorldDemo Activity is created by default onCreate method will be executed. inside onCreate Method we have an setContentView which execute the android application design file whose name is main.xml  because we have R.layout.main as an argument.
In Brief  AndroidManifest.xml file execute the Launcher Activity class and from the launcher activity onCreate method will execute the Design View file by using setContentView method.


Android Apk
Read More..

Android Hello World Application Example For Beginners

| 0 comments |
Create “Hello World” application. That will display “Hello World” in the middle of the screen in the
red color with white background.

Click Below Link to download Hello World Application. Although i recommend you to read below steps to understand how to develop Android Application

Download Hello World Android Application

Create Hello World Application follow these basic steps. Below Steps are after the configuration of SDK Manager and eclipse.
STEP 1
Start Eclipse and Choose Workspace where you want to save your project

STEP 2 
Click on the file menu -> Select New -> Choose Android Project
 New Android Project Dialog will displayed and fill the required information and click on the finish button



Here In Above Dialog box Create Activity is the name of class you want to specify for your default Activity which will be loaded first when Hello World Example will be executed.


STEP 3
From the Project explorer click on the HelloWorld  -> res - > layout. it will show the main.xml inside layout folder. double click on the main.xml. By clicking on main.xml it will show something like.

Drag the Text View Control from  left panel to black box. and click on the main.xml tab show bottom left near Graphical Layout. now the main coding or designing part starts.

Main.xml file content for Hello World Example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android_orientation="vertical"
    android_layout_width="fill_parent"
    android_layout_height="fill_parent"
    android_background="#999">
 
    <TextView
        android_layout_height="fill_parent"
        android_text="Hello World"
        android_textColor="#900"
        android_id="@+id/textView1"
        android_layout_width="fill_parent"
        android_gravity="center_vertical|center_horizontal">
    </TextView>


</LinearLayout>

STEP 4
When you drag  control to Graphical Layout  in background it will generate the xml code appropriate to those control. In our Example we have dragged TextView Control so here we can see the TextView tag. and LinearLayout tag. LinearLayout is the default layout which hold the View Control as well other Layout if you want to specify for your design.



TextView

We have android:text = "Hello World"  attribute which show the text to screen. here we have specified "Hello World".

android:textColor="#900"  you can specify the Text Color in RGB format RED , GREEN and BLUE.
android:layout_height="fill_parent"  TextView Control Height would be equal to the height of its parent control. in our example parent is LinearLayout. same thing would be applied to android:layout_width

android:gravity="center_vertical|center_horizontal"   you can specify the alignment of the control

LinearLayout

android:background="#999"   We have Specified the Background color of LinearLayout to White Color

STEP 5
Click on the run  to execute our Hello World Application Example.


Download Hello World Android Application


Android Apk
Read More..