Android Splash Screen Activity

Hi . ..to all ..today i’m going to share about android splash screen activity .

Now Most of the applications coming with splash screen .Before going into session ,make sure you have made the development environment to develop application in android.

Development tools needed for Android are

1.Eclipse

2.Java Runtime Environment

3.Android ADT and Android Sdk

4.Android API

You can develop application from “Android Studio” also . Its upto to you people. I’m not going to tell about installations and and setting up environment.You can find lot of good tutorials to do this.

Here in this session i’m telling about developing app in Eclipse

Open up Eclipse and create new Android Application Project.

project name i given here is FreeTamilEbooks

package name for me here is com.ebook.freetamilebooks

If you created project in eclipse means you can see the file structure like this

Screenshot from 2013-10-01 21:02:16

in src folder you can see java files.

in layout folder you can see xml files.

 

Things to remind here .

UI part of the application was done in xml in layout folder.

The coding Part done in java in src folder.

Confusing ?? let me clear this.

UI in the sense , lets imagine a button in a screen,

now for creating a button in a screen you have to use xml in android (dynamically can create in java)

For Actions like clicking a button etc . have to be coded in java .

now got clear with this. I hope u got some idea about this.

now open up java file in src folder .My java code with splashscreen.java

package com.ebook.freetamilebooks;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;

public class SplashScreen extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_splash_screen);
		 Handler handler=new Handler();
	        handler.postDelayed(new Runnable()
	        {               
	            @Override
	            public void run() 
	            {
	                Intent intent = new Intent(SplashScreen.this,Home.class);
	                startActivity(intent);
	                SplashScreen.this.finish();                         
	            }
	        }, 3000);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.splash_screen, menu);
		return true;
	}

}

java code for second Screen Home.java

package com.ebook.freetamilebooks;

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

public class Home extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home);
	}

}

my xml codes are 
activity_splashscreen.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/splash"
    tools:context=".SplashScreen" >
</RelativeLayout>

my home.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TextView 
        android:id="@+id/welcome"
        android:layout_width="fill_parent"
         android:layout_height="fill_parent"
        android:text="Welcome to home "/>
</LinearLayout>

Finally one important thing to do with AndroidManifest.xml

this xml file is like guidemap . While running our app this file gets executed first and tell the activites ,and necessary things to the emulator.

Android uses DVM (Dalvik Virtual Machine) . It combines java and xml code into .apk format.
java files gets compiled by JVM(Java Virtual Machine)

By default your very first activity is specified in this file. If you have more than one activity you have specify the activities in this file. Else your application won’t work .

AndroidManifest.xml

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.ebook.freetamilebooks.SplashScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       <strong> <activity
            android:name="com.ebook.freetamilebooks.Home"
            android:label="@string/app_name" >
        </activity></strong>
    </application>

</manifest>

one last thing to do for splash screen . We need an image to show at very first screen of our app.

so choose your image .It must be in .pngformat.
create folder named drawable under /resdirectory in eclipse.

Here i named the image as splash.png . I used that image as in activity_splash.xml like this
android:background=@drawable/splash[/sourcode]

you can give any name to your image and make sure same name in while using in xml file too.

Thats it . Now save your file and press Contrl+F11

After home launched from emultor you can see the page like this

Screenshot from 2013-10-01 23:02:00

Thats it. Thanks for reading. Happy coding!!!

Android User Interface Design Basics

Hi.. to all.. today i’m going to share about android UI(User Interface) design .

UI:

your UI plays very import role in android application. User can see your User Interface(UI) and interact with your app.

Android provides some pre-built UI components such as structured Layout objects etc.

What is a Layout ?

Layout defines what is drawn on your screen ..In other words, it defines the visual structure of a user interface.

What are the Layouts in Android?

  • Linear Layout
  • Relative Layout
  • Table Layout
  • Frame Layout
  • Grid View
  • List View
  • Scroll View 

Linear Layout:

Linear Layout allows that all it’s child to a single direction either “Vertical ” or “Horizontal“. we can choose the orientation by android:orientation=”vertical/horizontal”

linear

Relative Layout:

Relative layout displays child views in relative positions. The position can be specified as left or right to siblings or below to particular  siblings or it may center .

Getting confused ???

let me clear with sample design..

take an example of  our gmail login page.

relativ1

Username is left to field of EditText(we call this as edittext  in android ).

similarly Password field is left to another field and also below to Username field

here Sign in Button is center of the screen .

Now you got the clear idea about to use relative layout in android i think..

List view:

List View is a view group that displays list of scrollable items. Items    are inserted into list view using  Adapter.  The source of an Adapter may be Array or database query that puts query results  into list view.

We will see about list view in my upcoming posts..

Grid View:

Grid View is a View Group in android that displays the items in  two-dimensional, scrollable grid. Items are  inserted into Grid View using ListAdapter. See the image for grid view below.

grid

Scroll View:

 Scroll View allows user to scroll the page or screen in android. One of the most important thing about Scroll View to remember is, Scroll View can have only one child.

we will see about Scroll View in my upcoming posts.

Table Layout:

A layout that arranges its children into rows and columns.  Our calculator is the best example for   Table Layout in android.

Hope you liked it.. Thanks for reading…

Android Basics

Hi.. to all ..I’m going to share my Android experience with you . I’m not an expert in android. I’m just a Android Application Developer .I will try to explain all my  posts as easy  for a beginner to understand .

Before going to into the session . I want you to have  some basic knowledge in java or oops . Because in android we are going to code in java.

What is Android?

Android is a Linux based Operating System primarily designed for mobiles such as Smartphones,tablets etc.

Basic Components of Android:

  • ACTIVITY
  • SERVICES
  • INTENT
  • CONTENT PROVIDER

ACTIVITY:

Activity is the building block of UI(User Interface). Almost all of the activities interact with the user .

INTENT:

Intents are system messages, running around inside of devices and notifying applications such as (e.g) New message arrived ,SD inserted . etc. You can not only respond to intents you can create your own intent to launch other activities . I will explain in my upcoming posts.

CONTENT PROVIDER:

Content Provider provides a level of abstraction that makes our application data accessed by multiple applications. In short, it makes our application data available to other applications . You can create your own content Provider. I will explain about this later. Android has some default Content provider class such as

(e.g) Contacts Content provider in Android

import android.provider.ContactsContract.Contacts;

by importing this you can access your contacts (Note: read ,write permissions should be given in order to use this in your application)

SERVICES:

Activity,intents,content provider are short-lived process they can be killed at any time. But services are long lived process , running in background .

(e.g) You are playing songs in music player in your mobile . Are you still in music player to listen songs? after playing any song we came out to some other screen from player. but player continues to play songs even though we are not in that screen. This is called service in Android.

Thanks for reading ..