Wednesday 24 December 2014

Hello World in Android more details


This tutorial explains provides you some basic explanation about the Android application project.

Following are the list of items which needs to be known when creating a simple application.

1)      Activity:
Activity is the one which provides screen to the user where he can interact with the application. There should be at least one activity in your Android application to run. Whenever an application icon is clicked any one Activity will be started.

2)      Layout:
Layout is one which defines how your application screen should look like. The layout that we use in the HelloWorld application is RelativeLayout. Which sets the items in a sequence based on other items. In every Android project there will be a folder called LAYOUT in which all the layout design files are stored in XML format.

3)      AndroidManifest.XML:
This file contains the configuration details of our Android application, the minSDK and targetSDK. List of permission that the application need access i.e internet, camera etc.., the first activity that needs to be run when the application launches. What’s the display name of the application, the theme that needs to be used etc.

Below is the file sample file of an Android application.

xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.skk.helloWorld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            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>


4)      Values folder:
This section in the Android project contains the strings, styles, format of the UI elements etc. Below is the sample strings.xml which contains the strings and its values.

xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Hello Kumar</string>
    <string name="hello_world">Hello Kumar!</string>
    <string name="action_settings">Settings</string>

</resources>


5)      Drawable folders:
This section contains all the images that are used in the Android application. The images with various resolutions are kept in separate folders.

The above are the basic details that needs to be known for a sample application. Details in depth will be explained in separate posts.

Please provide your comments below the blog.

No comments: