how can add jar library

create folder lib in you project
and after put the jar into lib folder

and then , right click on your project ->property -> Java Build path->on Libraries , add jar file
->ok

Activity life cycle of Android



create XML file android



       String HEADER_TAG="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
String ROOT_TAG_NAME="Example";

String TAG_START_FRIST="<";
String TAG_START_END=">";

String TAG_END_FRIST="</";
String TAG_END_END=">" ;
String TAG_NAME_ARRAY[]={

               "No","City","State"
             };
String TAG_VALUE[]={

        "1","kolkata","West bengal",
        "2","delhi","Delhi",
        "3","pune","Maharastra",
        "4","bengalor","AP","5","mumbai"
       
       };


in your main use this


String returnXML;
-------------------     returnXML=myXMLCreator(ROOT_TAG_NAME,TAG_NAME_ARRAY,TAG_VALUE);



=======================================================================

Use this mathod and paraMeterPass Value from the main

private String myXMLCreator(String mROOT_TAG_NAME,String mTAG_NAME_ARRAY[],String mTAG_VALUE[]) {




if((mTAG_VALUE.length)%(mTAG_NAME_ARRAY.length)!=0)
{
int rem;
 rem=(mTAG_VALUE.length)%(mTAG_NAME_ARRAY.length);

String msg=" tag name array and value array not same ";
Log.v(" ERROR  ",msg);
      }



String XMLString=HEADER_TAG+"\n"+
           TAG_START_FRIST+mROOT_TAG_NAME+TAG_START_END+"\n";

         for(int i=0,j=0;j<mTAG_VALUE.length;i++,j++)
          {
              XMLString=XMLString+TAG_START_FRIST+mTAG_NAME_ARRAY[i]+TAG_START_END;
           
          XMLString=XMLString+mTAG_VALUE[j];
         
              XMLString=XMLString+TAG_END_FRIST+mTAG_NAME_ARRAY[i]+TAG_END_END+" \n ";
           
          if(i==2){
         
            i=-1;                                    // one array store all data and tag have three
           }
                                                                 // after  3 time change value from the 0
          }
 
   XMLString=XMLString+TAG_END_FRIST+ROOT_TAG_NAME+TAG_END_END;

return XMLString;
     }

how can i get my current gps location android

project Name : MyCurrentLocation
target : 2.1
menifest permission :  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

activity Name : MyCurrentLocationActivity.java


MyCurrentLocationActivity.java coding
====================================


public class MyCurrentLocationActivity extends Activity
{
Button btnGps;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

btnGps=(Button)findViewById(R.id.button1);

btnGps.setOnClickListener(new OnClickListener() {
  @Override
public void onClick(View v) {
// TODO Auto-generated method stub
 
  /* Use the LocationManager class to obtain GPS locations */
  System.out.println( "Click ....");
 
  LocationManager mylocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  LocationListener mlocListener = new MyAApsLocationListener();
  mylocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
}
});

}


/* Class My Location Listener */

public class MyAApsLocationListener implements LocationListener
{
    public void onLocationChanged(Location loc)
      {
loc.getLatitude();
loc.getLongitude();

Toast.makeText( getApplicationContext(),"My current location is: " +" Latitud = " + loc.getLatitude() +" Longitud = " + loc.getLongitude(),Toast.LENGTH_SHORT).show();
   }


   @Override
     public void onProviderDisabled(String provider)
{
    Toast.makeText( getApplicationContext(),"Gps Disabled",Toast.LENGTH_SHORT ).show();
}


  @Override
     public void onProviderEnabled(String provider)
      {
       Toast.makeText( getApplicationContext(),"Gps Enabled",Toast.LENGTH_SHORT).show();
      }


     public void onStatusChanged(String provider, int status, Bundle extras)
     {
     }

    }

}

//////////////////////////////////////main.xml////////////////////////////////////////



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

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />


    <Button
        android:id="@+id/button1"
        android:layout_width="85dp"
        android:layout_height="wrap_content"
        android:text="Get GPS" />

</LinearLayout>

/////////////////////////////////////////// Menifest.xml ///////////////////////////////////////////////////



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

    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MyCurrentLocationActivity"
            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>

///////////////////////////////////////////////////////////////////////////////

if you run this application on real device then fine :
but if you run  AVD then you need to provide lat long by
 Emulator Control ,which you can find by this path
eclipse->window->show View->Emulator Control
then ,
           






















how can set image on imageview from URL android



use This mathod

private void loadImage(String url) {
     try {

 Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());
 imageView.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
 e.printStackTrace();
} catch (IOException e) {
 e.printStackTrace();
}

}

IRCTC Share Price Declines by 2% Despite 30% Jump in Q4 Net Profit; Board Announces Dividend of INR 2 per Share

Introduction: The share price of Indian Railway Catering and Tourism Corporation (IRCTC) experienced a decline of 2% in today's trading ...