Friday, April 22, 2011

Publishing FaceBook Checkin a place in Android


Step 1: In-order to publish a place via checkin we are in need of the following parameters

1. Access Token
2. Place which is to be Checkin
3. Message which will display to your friends
4. Latitude and Longitude of that place
5. Tag i.e. User Id

Step 2: Use Bundle to wrap the above parameters

Bundle params = new Bundle();
params.putString("access_token", Main.access);
params.putString("place", "203682879660695");
params.putString("Message","I m here in this place");
JSONObject coordinates = new JSONObject();
coordinates.put("latitude", Main.mylat);
coordinates.put("longitude", Main.mylong);
params.putString("coordinates",coordinates.toString());
JSONArray frnd_data=new JSONArray();
params.putString("tags", "xxxx");//where xx indicates the User Id

Step 3:  Call the Request method and check whether proper response you had got

String response = faceBook.request("me/checkins", params, "POST");
Log.d("Response",response);

Adding Tabs dynamically in Android


Step 1: Create a xml name tabhost.xml, for desigining the Tab Host, as i shown below
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:tag="tabPane"
/>
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/address_bar"
android:layout_width="270px"
android:layout_height="50px"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<ImageButton
android:id="@+id/add_btn"
android:layout_width="50px"
android:layout_height="50px"
android:src="@android:drawable/ic_menu_add"
android:background="@android:color/transparent"
android:layout_toRightOf="@id/address_bar"
/>

</RelativeLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="2dp" />
</LinearLayout>
</TabHost>



Step 2:  Create a Activity which extends TabActitvity as i shown below


public class Main extends TabActivity{

private TabHost tabHost;
private EditText addressBar;
  private final static String DEFAULT_URL = "http://www.google.com/";
private int z = 0;
private String SanTest=null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs_main);

this.tabHost = getTabHost(); // The activity TabHost
this.addressBar = (EditText) findViewById(R.id.address_bar);
this.addressBar.setText(DEFAULT_URL);


ImageButton addBtn = (ImageButton) findViewById(R.id.add_btn);

addBtn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

  addMethod();  // Method which adds the Tab Host
}
});
Intent openBrowser = new Intent();
openBrowser.setClass(Main.this, Browser1.class);
openBrowser.putExtra("URL", DEFAULT_URL);
SanTest=Intent.CATEGORY_LAUNCHER;
Log.d("SanTest",SanTest);
tabHost.addTab(tabHost.newTabSpec("Main").setIndicator(getHost(DEFAULT_URL)).setContent(openBrowser));


}




private void addMethod() {

String webSiteURL = validateURL(addressBar.getText().toString().trim());
String webSiteName = getHost(webSiteURL);

Intent openBrowser = new Intent();
openBrowser.setClass(this, Browser1.class);
openBrowser.putExtra("URL", webSiteURL);

tabHost.addTab(tabHost.newTabSpec(webSiteName + Integer.toString(z)).setIndicator(webSiteName).setContent(openBrowser));
Log.d("z",Integer.toString(z));
++z;

}

private void deleteMethod() {

// Since we can't really delete a TAB
// We hide it

int position = tabHost.getCurrentTab();
Log.d("Position",Integer.toString(position));


// if (position != 0 ) {
//
// tabHost.getCurrentTabView().setVisibility(1);
// tabHost.setCurrentTab(position-1);
//
// }
// else if(position== z){
// tabHost.getCurrentTabView().setVisibility(1);
// tabHost.setCurrentTab(position+1);
// }
Log.d("Z val in delete()",Integer.toString(z));
if(position >0)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(position+1);
z-=1;
if(z<0)
z=0;
}
else if(position == 0)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(position+1);
z=0;
}
else if(position == z)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(z-1);
Log.d("Z value in final","lol");
Log.d("Pos",Integer.toString(position));
Log.d("z pos",Integer.toString(z));


}


}

// Inflates menu when "menu Key" is pressed
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.title_icon, menu);
return true;
}

// This method is called once the menu is selected
@Override
public boolean onOptionsItemSelected(MenuItem item) {


switch (item.getItemId()) {

case R.id.add:

addMethod();

break;

case R.id.delete:

deleteMethod();

break;
}
return true;
}

private String validateURL(String url) {

StringBuffer urlB = new StringBuffer();

// checks if addressBar has a valid URL
// you can add stuff here in order to validate
// this is just an example
if (url.startsWith("http://")) {urlB.append(url);} else {urlB.append("http://");}

try {
URL urlTry = new URL(urlB.toString());

return urlB.toString();

} catch (MalformedURLException e) {

return "http://www.google.com/";
}
}

private String getHost(String url) {

try {

URL urlTry = new URL(url);

return urlTry.getHost().replace("www.", "").replace(".com", "").replace(".org", "").replace(".net", "");

} catch (MalformedURLException e) {

return "Browser";
}
}

}
 
Step 3:  Inside an XML , which will display the Web View

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
>
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webview"

/>
</LinearLayout>

Step 4:  Create the Activity which load the url in WebView

public class Browser1 extends Activity {

private WebView webview;

private String URL;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.broswer);
webview = (WebView) findViewById(R.id.webview);

Bundle extras = getIntent().getExtras();
Log.d("I m before If","1");
if (extras == null) {
Log.d("I m in if condition","1");
URL = "http://www.google.org/";

} else {
Log.d("I m in else condition","2");
this.URL = extras.getString("URL");
Log.d("URL",this.URL);
}

getWebView();

}

public void getWebView() {
//Log.d("GetWebView Invoked", URL);
webview.loadUrl(URL);
webview.setWebViewClient(new HelloWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);

}

private class HelloWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}

}

 Step 5:  Output Screen Shot







Dynamically Loading Data's (Adding Footer to ListView ) in ListView in Android


Add a footer to List View and when the user clicks that Footer, you can show parse the next set of data and show it in the list.



Step1: Create a Button

<Button android:id="@+id/footer" android:gravity="center"
android:layout_gravity="center"
android:text="My Footer"
android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_weight="1"/>

Step2: Make it as Footer to the List View

ListView myList;
View footerView;
ViewGroup footerViewOriginal = (ViewGroup) findViewById(R.id.footer);
footerView = inflater2.inflate(R.layout.footer,footerViewOriginal);
footerView.findViewById(R.id.footer);
myList.addFooterView(footerView, null, true);

Step3: Create on ClickListener and write the action what you want to perform

footerView.findViewById(R.id.footer).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;

}

Singleton Class in Java

     

           A Singleton class is used when you wish to restrict instantiation of a class to only one object.
           Suppose we have to retain the values of the Variables and want to restrict the creation of more than objects then we can use Singleton pattern.

Step 1: Create a Class which extends Observable, as i shown below

public class Viewmore extends Observable {


// create the Instance of Viewmore as static ,since make that object as class Variable

private static Viewmore instance;

private Viewmore() {
/** Default Constructor(Empty Constructor) */
}

// Create a method , which checks whether the instances is already created or not

public static Viewmore getInstance() {
if (instance == null) {
instance = new Viewmore();
}
return instance;
}

Step 2: Cerate the Singleton Object as i Shown below

class Samp {

// Create the Instance of Singleton 

Viewmore vm = Viewmore.getInstance();

}
 





Wednesday, April 20, 2011

Using SharedPrefrenced in Android?



Step1: create a project as Usual

Step2: create the xml and code like this


<?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"
>

<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cropToPadding="true"
android:background="@drawable/mylog"
android:adjustViewBounds="true"

/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"

>
<TextView
android:text="User Name:"
android:textColor="#AF8717"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:textSize="22sp"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_marginTop="45dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/myuserlabel"
/>

<EditText
android:layout_toRightOf="@+id/myuserlabel"
android:textColor="#AF8717"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:textSize="22sp"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/userval"
android:ellipsize="end"
/>


<TextView
android:layout_below="@+id/myuserlabel"
android:text="Password:"
android:textColor="#AF8717"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:textSize="22sp"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_marginTop="60dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mypwdlabel"
/>

<EditText
android:layout_toRightOf="@+id/mypwdlabel"
android:layout_marginTop="130dp"
android:textColor="#AF8717"
android:layout_weight="1"
android:textSize="22sp"
android:textStyle="bold"
android:password="true"
android:layout_marginLeft="35dp"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/mypwdval"
android:ellipsize="end"


/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/submit"
android:layout_below="@+id/mypwdlabel"
android:layout_marginTop="80dp"
android:layout_centerInParent="true"


/>


</RelativeLayout>

Step 3 :Java code


public class DemoActivity extends Activity
{
EditText u_name=null,pwd=null;
Button mylogin_submit;

/* Creation of Shared Preferences */

public static final String PREFS_NAME = "MyShardedprefernce";
static SharedPreferences settings;
SharedPreferences.Editor editor;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.id.main);
u_name=(EditText)findViewById(R.id.userval);
pwd=(EditText)findViewById(R.id.mypwdval);
mylogin_submit = (Button)findViewById(R.id.submit);

mylogin_submit.setOnTouchListener(new OnTouchListener (){


@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
username=u_name.getText().toString();
Log.d("UserName",username);
password=pwd.getText().toString();

//store it in shared perfernce

editor=settings.edit();
editor.putString("UserName",username);
editor.putString("Password",password);
Intent myintent=new Intent(DemoActivity.this,NewActivity.class);
startActivity(myintent);

return false;
}});


}


Step 4: Create another class , where we are reterving the value stored in Shared Prefernce


public class NewActivity extends Activity {

public static final String PREFS_NAME = "MyShardedprefernce";
static SharedPreferences settings;
String username, password;
TextView t,t1;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.id.newui);
settings = getSharedPreferences(PREFS_NAME, 0);

username= settings.getString("UserName","No Data Found");
password= settings.getString("Password","No Data Found");

t=(TextView) findViewById(R.id.Username);
t1=(TextView) findViewById(R.id.pwd);

t.SetText("Welcome User:"+username);
}
}

Creating Custom Text View in Android?


Step 1: Create a Layout in xml file as i did below

<LinearLayout android:id="@+id/san_tag" android:layout_width="wrap_content" android:layout_height="wrap_content">


</LinearLayout>

Step 2:  Now Map that Layout in Java Code as i Shown Below

LinearLayout navagtion_bar;
String myarray[]={"Foot Ball","Basket Ball","Cricket"};
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
navagtion_bar= (LinearLayout) findViewById(R.id.san_tag);// Map the Layout
 TextView bs_text[]= new TextView[myarray.length]; // Create TextView according to value in length variable;

for(int z=0;z< myarray.length] ;z++)
{
try
{

bs_text[z] = (TextView) new TextView(this);
bs_text[z].setText( myarray [z]);
bs_text[z].setTextSize(15);
bs_text[z].setBackgroundColor(android.graphics.Color.TRANSPARENT);
bs_text[z].setTextColor(android.graphics.Color.BLACK);
navagtion_bar.addView(bs_text[z]);
}
}
catch(ArrayIndexOutOfBoundsException e)
{
Log.d("ArrayIndexOutOfBoundsException",e.toString());
}
}

Step 3: Set the Click Listener Custom TextView

do
{

    bs_text[y].setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
           Log.d("I m clicked","Y Value"+Integer.toString(y));
    });
y--;
}while(y>=0);







Saturday, April 16, 2011

Parsing Data from XML Using DOM & Displaying it in a ListView in Android ?


Notice three methods which i had shown below, they are
1. getElementsByTagName - Mention the tag which you want to parse
2.getChildNodes - retervies the child node
3.getNodeValue()- with the help of this method you can access the
value of particular tag
 


Step 1 : Create a List View in the xml as i shown below

<?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" >

<ListView android:id="@+id/mylistview" android:layout_width="fill_parent" android:layout_height="fill_parent"></ListView>

</LinearLayout>

Step 2:  Now Create an XML which determines the Inner Content of List View

<?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">

<ImageView android:id="@+id/myimgview" android:layout_width="wrap_content" android:layout_height="wrap_content" />

<TextView android:layout_toRightOf="@+id/myimgview" android:id="@+id/mytextview" android:layout_width="wrap_content" android:layout_height="wrap_content" />

</RelativeLayout>


Step 3:  Now Create a Activity which maps the List View in the XML

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ListView;

public class MyActivity extends Activity {

ListView listcomp=null;
 MyAdapter adapt_obj=null; // Create a Object for Adapter Class
Context myref=null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
  listcomp=(ListView)findViewById(R.id.mylistview); // Map the List View Here
myref=MyActivity.this;
  new MyAsyncTask().execute(); // Call the Async Task

}

private class MyAsyncTask extends AsyncTask<Void,Void,Void>{

private final ProgressDialog dialog=new ProgressDialog(MyActivity.this);

@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
  adapt_obj=new MyAdapter(myref,"http://synd.cricbuzz.com/score-gadget/gadget-scores-feed.xml");

return null;
}

@Override
protected void onPreExecute()
{
dialog.setMessage("Loading ...");
dialog.show();
dialog.setCancelable(false);
}

@Override
protected void onPostExecute(Void result)
{
if(dialog.isShowing() == true)
{
dialog.dismiss();
}
listcomp.setAdapter(adapt_obj);
adapt_obj.notifyDataSetChanged();
}
}
}

Step 4: Create a Adapter which extends Base Adapter


import java.io.InputStream;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter {

LayoutInflater inflation=null;
Context mycontext=null;
String urlvalue=null,roottag=null,parseelement=null;
MyParser myparseobj=null;
String[] title_array=null,image_array=null;

MyAdapter(Context c,String url)
{
Log.d("1","1");
mycontext=c;
inflation=LayoutInflater.from(mycontext);
myparseobj=new MyParser();
  title_array=myparseobj.xmlParsing(url,"match","description");
  image_array=myparseobj.xmlParsing(url," match ","image");
}


@Override
public int getCount() {
// TODO Auto-generated method stub
Log.d("title_array",title_array.length+"");
return title_array.length;
}

@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}

@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
MyHolder holder=new MyHolder();;
if(convertView == null)
{
convertView=inflation.inflate(R.layout.listcontent, null);

holder.tv=(TextView)convertView.findViewById(R.id.mytextview);
holder.iv=(ImageView)convertView.findViewById(R.id.myimgview);


}
else
{
holder.tv=(TextView)convertView.findViewById(R.id.mytextview);
holder.iv=(ImageView)convertView.findViewById(R.id.myimgview);

}

holder.tv.setText(title_array[position]);
try{
String temp=image_array[position];
InputStream is= new java.net.URL(temp).openStream();
Bitmap b=BitmapFactory.decodeStream(is);
holder.iv.setImageBitmap(b);
}
catch(Exception e){}

return convertView;
}

static class MyHolder
{
TextView tv=null;ImageView iv=null;
}
}

Step 5:  Parse the Given Url, using DOM or SAX,  I had used DOM

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
//import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import android.util.Log;

public class MyParser {

public String[] xmlParsing(String fetchurl,String roottag,String parseelemnt)
{
String[] temp=null;
URL url=null;
Log.d("I m Here","2");
try {
url = new URL(fetchurl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
Log.d("I got Exception","3");
e.printStackTrace();
}
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db=null;
try {
db = dbf.newDocumentBuilder();
}
catch (ParserConfigurationException e1) {
e1.printStackTrace();
Log.d("I m Here","4");
}
Document doc=null;
try {
doc = db.parse(new InputSource(url.openStream()));
} catch (SAXException e2) {
// TODO Auto-generated catch block
Log.d("I m Here","5");
e2.printStackTrace();
} catch (IOException e3) {
// TODO Auto-generated catch block
Log.d("I m Here","6");
e3.printStackTrace();
}
org.w3c.dom.Element elt=doc.getDocumentElement();
NodeList nodeList = elt.getElementsByTagName(roottag);
temp=new String[nodeList.getLength()];
Log.d("the length of nodelist",Integer.toString(nodeList.getLength()));


for (int i = 0; i < nodeList.getLength(); i++)
{
Node node = nodeList.item(i);

NodeList titleList = node.getChildNodes();
Log.d("The length of titlelist",Integer.toString(titleList.getLength()));


for(int j=0;j<titleList.getLength();j++)
{
Node node1= titleList.item(j);
String name = node1.getNodeName();

if (name.equalsIgnoreCase(parseelemnt)) {

Log.d("J value"," "+j);
temp[i]=node1.getFirstChild()
.getNodeValue();

Log.d("temp value",temp[i]);
}
}
}



return(temp);


}

}



Thursday, April 7, 2011

Performing Animation in Android


Step1: create anim folder under res directory in ur project.

Step2: create an slideleft.xml file

Step3: type the following code in that file

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="400" />
</set>

step 4: similarly create slideright.xml

step5: use the above code, but change the following

<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="400" />

step 6:

target.startAnimation(AnimationUtils.loadAnimation(HomeScreen.this, R.anim.slide_left));

perfroming fadein operation, just add the following code in fadein.xml file

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

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="300" />

similarly for fade out too

<?xml version="1.0" encoding="UTF-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="300" />

Creating a Splash Screen in Android

Creating a Splash Screen in App in Android.

Android Project Structure:

src folder has packages which contains our source code

gen folder which is generated by android complier to map the xml components in Java code.

res folder contains drawable , layout, anim, raw,values folder, drawable is manily for image handling and layout folder contains xml codes and anim folder is for holding animation files and raw folder is storing for excel files as well as Music files and values folder hold the gobal variables.

Step 1: For Designing an UI, we have to code in xml,

Create a xml file, namely myui.xml Note: use small char when you naming the xml files

The first line of your xml must be this line to indicate to android complier which version and encoding type of our xml is using

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

Then create a Layout , we have four different types of layout, they are Linear Layouts and Relative Layouts and Absolute Layout and Table Layout.

Linear layout is used when the UI components are arranged in an linear manner either in horizontal or veritical.

Relative Layout is used when there is a relationship b/w the UI componenets

Absolute layout is used when UI components are hardcoded.

Tablelayout is when the UI has to be arranged in the form of Rows and Columns.


For Splash Screen App, we choose Linear layout and set the Image as background to Linear layout as i shown below

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mysplashimg">


Step2: Creating Java Code

Extend your java class from android Activity class, and donot forget to override onCreate method


package declaration

public class MyActivity extends Activity
{

// create and set value for CountDown Timer Object

MyCount counter = new MyCount(5000, 1000);

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

// Map your UI in xml here as shown i below

setContentView(R.layout.myui);

counter.start(); // Start the Count Down Timer
}
}

Step 3: Create a Class which extends CountDown Timer



class MyCount extends CountDownTimer {

public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);

}

public void onFinish() {

// Finish your Splash screen and Jump to other Activity with the help of Intent

Intent my_intentObj= new Intent(Currentclass.this, Movableclass.class);

startActivity( my_intentObj);
}

@Override
public void onTick(long millisUntilFinished) {

// TODO Auto-generated method stub
}
}

Notification in Android Using AlarmManager, BoradCastReceiver & Services

    Our aim is to show notification message to user in a specific time.     Say For example , I have planned to show Notification ...