how can i get my current location by GPS android

Project Name :MyCurrentLocation
Activity Name : MyCurrentLocationActivity.java
Target : 2.1
package : com.myandroid.location;
 uses permission        android:name="android.permission.ACCESS_FINE_LOCATION" in menifest
MyCurrentLocationActivity.java coding
=============================


package com.myandroid.location;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

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 / /////////////////////////////////////


<?xml version="1.0" encoding="utf-8"?>
<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>

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


when you run the application you must send the lat / long by
Emulator control

you can get Emulator control from the

menu :
window - >Show view - > Emulator Control

and send manual lat log 





how can you get image from the imaview and change to bimmap


     private Integer mImageIds[] = {
R.drawable.image1,
R.drawable.image2,
                         R.drawable.image3,
          };



 Resources res=you_class_name.this.getResources();
     Drawable dra=res.getDrawable(mImageIds[myposition]);        // myposition is spacifi position to the array
       set_imageview.setImageDrawable(dra);
    Bitmap bitmap = ((BitmapDrawable)dra).getBitmap();
        System.out.println(" SAve To Image :"+bitmap);              // you see the bitmap

how can you set image run time on image view



imageView.setBackgroundDrawable(drawableObject);
imageView.setBackgroundResource(R.drawable.yourFileInDrawable);

how can i set SCREEN ORIENTATION PORTRAIT ,SCREEN ORIENTATION BEHIND , SCREEN ORIENTATION LANDSCAPE ,SCREEN ORIENTATION NOSEN,SCREEN ORIENTATION SENSO,SCREEN ORIENTATION UNSPECIFIED,SCREEN ORIENTATION USER


public static final int SCREEN_ORIENTATION_PORTRAIT
Since: API Level 1
Constant corresponding to

portrait in the

screenOrientation attribute.

Constant Value: 1

(0x00000001)

android code to set PORTRAIT screen :

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

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

/////////
public static final int SCREEN_ORIENTATION_BEHIND
Since: API Level 1
Constant corresponding to
behind in the
screenOrientation attribute.
Constant Value: 3
(0x00000003)
 android code to set BEHIND screen :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND);
////////////////////////////

//

public static final int SCREEN_ORIENTATION_LANDSCAPE
Since: API Level 1
Constant corresponding to

landscape in the

screenOrientation attribute.
Constant Value: 0
(0x00000000)

 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

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

///
  int android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSEN

SOR = 5 [0x5]
public static final int SCREEN_ORIENTATION_NOSENSOR
Since: API Level 1
Constant corresponding to
nosensor in the screenOrientation attribute.
Constant Value: 5

(0x00000005)

 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
//////////////////////////

int android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSO
R = 4 [0x4]
public static final int SCREEN_ORIENTATION_SENSOR
Since: API Level 1
Constant corresponding to
sensor in the screenOrientation attribute.
Constant Value: 4
(0x00000004)

  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
////////////////////////////

///
int android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED = -1 [0xffffffff]
public static final int SCREEN_ORIENTATION_UNSPECIFIED
Since: API Level 1
Constant corresponding to
unspecified in the screenOrientation attribute.
Constant Value: -1
(0xffffffff)
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
//////////////////////////

int android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER
= 2 [0x2]
public static final int SCREEN_ORIENTATION_USER
Since: API Level 1
Constant corresponding to
user in the screenOrientation attribute

Constant Value: 2
(0x00000002)

   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);

WHY DEVELOP FOR ANDROID ?



If you have a background in mobile application development, you don’t need me to tell you that:
. A lot of what you can do with Android is already possible.
. But doing it is painful.
Android represents a clean break, a mobile framework based on the reality of modern mobile devices
designed by developers, for developers.
With a simple and powerful SDK, no licensing fees, excellent documentation, and a thriving developer
community, Android represents an excellent opportunity to create software that changes how and why
people use their mobile phones.
From a commercial perspective Android:
. Requires no certification for becoming an Android developer
. Provides the AndroidMarket for distribution and monetization of your applications
. Has no approval process for application distribution
. Gives you total control over your brand and access to the user’s home screen

how can you show image with a text in list view android

Project Detail:
package com.android.listview;
Project Name :listView
Target :2.1
activity Name: ListViewActivity.java
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Xml detail : main.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">
  <LinearLayout
        android:id="@+id/linearLayout1"
       
        android:layout_width="match_parent"
        android:layout_height="67dp"
        android:orientation="horizontal" >
  <ImageView
            android:id="@+id/imageView1"
            android:layout_width="110dp"
            android:layout_height="match_parent"
            android:src="@drawable/ic_launcher" />
    <TextView
            android:id="@+id/textView1"
            android:layout_width="88dp"
            android:layout_height="fill_parent"
            android:layout_weight="1.54"
            android:text="test"
            android:textSize="20dp" android:textColor="#67ff12" android:background="#aaaaaa"/>

    </LinearLayout>

</LinearLayout>


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program detail :
 ListViewActivity.java
////////////////////////////////////////


public class ListViewActivity extends  ListActivity
{
final static ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>();

   static{
       HashMap<String, Object> row  = new HashMap<String, Object>();
       row.put("Icon", R.drawable.india);           // put india.png/jpg in drawable folder
       row.put("Chance", "Flag  India Large Style1");
       row.put("TeamID", "Albania");
       data.add(row);
       row  = new HashMap<String, Object>();
       row.put("Icon", R.drawable.indiaf);    // put indiaf.png/jpg in drawable folder
       row.put("Chance", "Flag  India Large Style1 ");
       row.put("TeamID", "RPA");
       data.add(row);
       row  = new HashMap<String, Object>();
       row.put("Icon", R.drawable.usa);  // put usa.png/jpg in drawable folder
       row.put("Chance", "Flag USA ");
       row.put("TeamID", "Polska :)");
       data.add(row);
       row  = new HashMap<String, Object>();
       row.put("Icon", R.drawable.img);  // put img.png/jpg in drawable folder
       row.put("Chance", "Immge Gif ");
       row.put("img", "test :)");
       data.add(row);
   }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
     
        SimpleAdapter adapter = new SimpleAdapter(this,
                data, R.layout.main , new String[] {"Icon","Chance","TeamID"}, new int[] { R.id.imageView1, R.id.textView1});         

       setListAdapter(adapter);
 
    }


how can you show simple tost android

 Toast.makeText(Recognizing_letter.this, " display your text ", Toast.LENGTH_SHORT).show();

how can you show simple ProgressDialog android


Simple ProgressDialog Show :


ProgressDialog  progressDialog;
progressDialog = new ProgressDialog(mContext);progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

progressDialog.setMessage("Loading...");

progressDialog.setCancelable(false);

how can you Drawing on lyout

package com.myandroid.kidsapp
Activity Name : Drawing.java
Target set :2.1

in this application have two java file and on xml that paint.xml

no need to take any permission into manifest.xml file
//////////////////////////////////////////////////////////////////
1. Drawing .java (main activity )


public class Drawing extends Activity implements OnTouchListener {

SignaturePad paint_llayout;
LinearLayout initpad1 ;
Button Btsave,btreset ,btSave;
ImageButton tvSeeting;
private int pos;

EditText inputFileName;

final String[] items = {
             "Red", "Green",
             "Blue","Black"
      };


String fileName;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.paint);
    initpad1=(LinearLayout)findViewById(R.id.linearLayout2_paint_paint);
        btreset=(Button)findViewById(R.id.btReset_paint);
        btreset.setOnTouchListener(this);
       
        btSave=(Button)findViewById(R.id.btSave_paint);
        btSave.setOnTouchListener(this);
       
        tvSeeting=(ImageButton)findViewById(R.id.img_setting_paint);
        tvSeeting.setOnTouchListener(this);
       

 
        // set canvas ///
       
      setSignatureCanvas();
     
      /////////////////
       
       
       
    }
       
        public boolean onTouch(View v, MotionEvent event)
    {
    switch(event.getAction())
    {
        case  MotionEvent.ACTION_DOWN :
    switch(v.getId())
      {
        case R.id.btReset_paint:
     
    break;
        case R.id.btSave_paint:
         
        break;
           }
                 break;
     case  MotionEvent.ACTION_UP :
          switch(v.getId())
            {
                 case R.id.btReset_paint :
                 paint_llayout.discard();
       
             break;
           
                 case R.id.img_setting_paint :
               
                 // alert Dialog for pic color Name //
               
                 AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setIcon(R.drawable.piccolor_sml);
                 builder.setTitle("Pick a color");
                           
                  builder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener()
                        {  
                      public void onClick(DialogInterface dialog, int item)
                      {  
                            pos=item;
                            SignaturePad.mPaint.setColor(0xFF000000);
                            Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
                        }}).setPositiveButton("Ok", new OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {

//* set color value as per select * //    

if(items[pos].equalsIgnoreCase("Red"))
{
   
       SignaturePad.mPaint.setColor(0xFFaa0000);
}
     else if(items[pos].equalsIgnoreCase("Green"))
  {
        SignaturePad.mPaint.setColor(0xFF00aa00);
  }
else if(items[pos].equalsIgnoreCase("Blue"))
 {
    SignaturePad.mPaint.setColor(0xFF0000aa);
   }
    else if(items[pos].equalsIgnoreCase("Black"))
      {
SignaturePad.mPaint.setColor(0xFF000000);
}
    else
    {
    SignaturePad.mPaint.setColor(0xFF000000);
    }

}
}).setNegativeButton("Cancel", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
     }
  });
                  builder.show();
             
             break;
     
                 case R.id.btSave_paint:
               
               
                 AlertDialog.Builder alert1 = new AlertDialog.Builder(this);
                 alert1.setTitle(" Save ");
                 alert1.setMessage("Put file name ");
                 alert1.setIcon(R.drawable.save_sml);

                 // Set an EditText view to get user input
               
                 inputFileName= new EditText(this);
               
                 alert1.setView(inputFileName);

                 alert1.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int whichButton) {
                               
                    fileName=inputFileName.getText().toString();
                   
                   if(fileName==null)
                    {
                      paint_llayout.save("default.PNG");
                    Toast.makeText(Drawing.this, "you must provied file name ? ", Toast.LENGTH_LONG).show();
                    }
                    else
                    {
                    paint_llayout.save(fileName+".PNG");
                    Toast.makeText(Drawing.this, " file "+fileName, Toast.LENGTH_LONG).show();
                    }
                 
            }
                 });

                 alert1.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int whichButton) {
                   
                   }
                 });

                 alert1.show();
               
                             
               break;
          }
     break;
     
    }
   
    return false;
   
       
         
   
    }
   
  private void setSignatureCanvas() {
     
    paint_llayout = new SignaturePad(Drawing.this);
initpad1.addView(paint_llayout.getSignaturePad());

}

////////////////////////////////////////////////////////////////
2.SignaturePad.java

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


public class SignaturePad extends View {

Context _context;
public static Paint   mPaint;
@SuppressWarnings("unused")
private MaskFilter  mEmboss;
@SuppressWarnings("unused")
private MaskFilter  mBlur;
private String filename;

private View v1;
MyView v;
private String storagePath = Environment.getExternalStorageDirectory().toString();

 
public SignaturePad(Context context) {
super(context);
_context = context;
v = new MyView(context);      
v1 = v.getRootView();
       
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setColor(0xFF000000);
             
     
        // mPaint.setColor(0xFFaa0000);
       
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(12);
        mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
                                       0.4f, 6, 3.5f);
        mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);

}



public View getSignaturePad()
{
//filename=filename1;
return v;
}

public void colorChanged(int color) {
        mPaint.setColor(color);
    }
public void discard(){
//mPaint.setARGB(0xff,125,125,125);
//v.mCanvas.drawPaint(mPaint);
v.mBitmap.eraseColor(0xFFAAAAAA);
v.invalidate();
}

    public class MyView extends View {

        @SuppressWarnings("unused")
private static final float MINP = 0.25f;
        @SuppressWarnings("unused")
private static final float MAXP = 0.75f;

        private Bitmap  mBitmap;
        private Canvas  mCanvas;
        private Path    mPath;
        private Paint   mBitmapPaint;

        public MyView(Context c,int col) {
            super(c);

            mPath = new Path();
            mBitmapPaint = new Paint(Paint.DITHER_FLAG);
        }

        public MyView(Context c) {
            super(c);

            mPath = new Path();
            mBitmapPaint = new Paint(Paint.DITHER_FLAG);
        }
        @Override
        protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);
            if(w > 0 && h > 0){
           mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
           mCanvas = new Canvas(mBitmap);
            }
        }

        @Override
        protected void onDraw(Canvas canvas) {
        // set backround color//
            canvas.drawColor(0xFFAAAAAA);

           
            canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

            canvas.drawPath(mPath, mPaint);
        }

        private float mX, mY;
        private static final float TOUCH_TOLERANCE = 4;

        private void touch_start(float x, float y) {
            mPath.reset();
            mPath.moveTo(x, y);
            mX = x;
            mY = y;
        }
        private void touch_move(float x, float y) {
            float dx = Math.abs(x - mX);
            float dy = Math.abs(y - mY);
            if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
                mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);
                mX = x;
                mY = y;
            }
        }
        private void touch_up() {
            mPath.lineTo(mX, mY);
            // commit the path to our offscreen
            mCanvas.drawPath(mPath, mPaint);
            // kill this so we don't double draw
            mPath.reset();
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            float x = event.getX();
            float y = event.getY();

            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    touch_start(x, y);
                    invalidate();
                    break;
                case MotionEvent.ACTION_MOVE:
                    touch_move(x, y);
                    invalidate();
                    break;
                case MotionEvent.ACTION_UP:
                    touch_up();
                    invalidate();
                    break;
            }
            return true;
        }
    }
   
   
    public void save(String fName){
   
    filename=fName;
   
        System.out.println("Root View : "+v1);
        v1.setDrawingCacheEnabled(true);
        Bitmap bm = v1.getDrawingCache();
        System.out.println("Bitmap : "+bm);
       // String filename = "sign.png";
try {
OutputStream fOut = null;
File file = new File(storagePath, filename);
fOut = new FileOutputStream(file);
if(bm != null)
bm.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(_context.getContentResolver(), file
.getAbsolutePath(), file.getName(), file.getName());
} catch (FileNotFoundException e) {
Toast.makeText(_context,
"Exception at save: File not found" + e.getMessage(),
Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(_context,
"Exception at save: IO stream error" + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
//Toast.makeText(_context, "Saved to: " + storagePath + "/" + filename,
//Toast.LENGTH_SHORT).show();
       
   }


}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
And main.xml file is :
in this case it is paint.xml



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











    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="79dp"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btReset_paint"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="0.02"
            android:text="Reset"
            android:visibility="visible" />



         <ImageButton
             android:id="@+id/img_setting_paint"
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:layout_weight="0.02"
             android:background="#000000"
             android:text="Setting"
             android:visibility="visible" android:src="@drawable/piccolor"/>
       
        <Button
            android:id="@+id/btSave_paint"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="0.03"
            android:text="Save"/>

    </LinearLayout>




    <LinearLayout
        android:id="@+id/linearLayout2_paint_paint"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.08"
        android:background="#ffffff"
        android:orientation="vertical" >

    </LinearLayout>

</LinearLayout>

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

now you can run the aaplication .................







image show in GridView

project name : imageGridView
target : 2.1
package  com.myandroid.gridView;

activity Name : ImageGridViewActivity
put image in drawable  name like - sample_i , sample_ii, sample_iii , sample_iv,

ImageGridViewActivity.java file are



public class ImageGridViewActivity extends Activity {

public static int pos,len;
ImageAdapter ia;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
       ia=new ImageAdapter(ImageGridViewActivity.this);
       len=ia.getCount();
       
        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ImageAdapter(ImageGridViewActivity.this));

        gridview.setOnItemClickListener(new OnItemClickListener() {
           
        public void onItemClick(AdapterView<?> parent, View v, int position, long id)
        {
        Intent intNext=new Intent(ImageGridViewActivity.this,imageShow.class);
        startActivity(intNext);
       
        pos=position;
                Toast.makeText(ImageGridViewActivity.this, "" + position, Toast.LENGTH_SHORT).show();
            }



        });
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

create anather class  ImageAdapter.java


public class ImageAdapter extends BaseAdapter {

private Context mContext;
 // references to our images
    private Integer[] mThumbIds = {
   
    R.drawable.sample_i,
    R.drawable.sample_ii,
    R.drawable.sample_iii,
    R.drawable.sample_iv,
   
            };

public ImageAdapter(Context c) {
       mContext = c;
   }
@Override
public int getCount() {
// TODO Auto-generated method stub
 return mThumbIds.length;

}

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

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

return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(mThumbIds[position]);
        return imageView;
    }


}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////    main.xml is:

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:columnWidth="120dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="30dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
/>

/////////////////////////////////////////////////////////////////////////////////////
your application is redy ...........









compare two bitmap from the res

package name :  com.myandroid.comImage;
Activity Name :ImageCompActivity
Target::2.1




public class ImageCompActivity extends Activity {
Bitmap bm1,bm2;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        Resources res=ImageCompActivity.this.getResources();
       
        // take image from the drawable folder and typecast as a Drawable//
       
        Drawable dra1=res.getDrawable(R.drawable.ic_launcher_i);
        Drawable dra2=res.getDrawable(R.drawable.ic_launcher);
       

// convert bitmap //
   bm1 = ((BitmapDrawable)dra1).getBitmap();
   bm2 = ((BitmapDrawable)dra2).getBitmap();
   System.out.println(" SAve To Image :"+bm1);
   System.out.println(" SAve To Image :"+bm2);
 

   if(imagesAreEqual(bm1,bm2))  // use imagesAreEqual() mathod for check two iamge equal or not //
   {
  System.out.println(" Two Image are Equal");
   }
       
   else
   {
  System.out.println(" Two Image are Equal");
   }
       
       
    }
   
    boolean imagesAreEqual(Bitmap i1, Bitmap i2)
    {
        if (i1.getHeight() != i2.getHeight())
        return false;
        if (i1.getWidth() != i2.getWidth()) return false;

        for (int y = 0; y < i1.getHeight(); ++y)
           for (int x = 0; x < i1.getWidth(); ++x)
                if (i1.getPixel(x, y) != i2.getPixel(x, y)) return false;

        return true;
    }
}

/////////////////////////////// XML////////////////////


<?xml version="1.0" encoding="utf-8"?>
<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" />

</LinearLayout>

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


take two image ic_launcher.png and ic_launcher_i.png



how can you play vedio



PalyTestActivity.class is the main activity class
=================================
import java.io.IOException;
import android.app.Activity;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class PalyTestActivity extends Activity implements SurfaceHolder.Callback
{
Button btStop;
private MediaPlayer mediaPlayer;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     
        btStop=(Button)findViewById(R.id.stop);
     
        mediaPlayer = new MediaPlayer();
        SurfaceView surface = (SurfaceView)findViewById(R.id.surface);
        SurfaceHolder holder = surface.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        holder.setFixedSize(400, 300);
     
     
     
        btStop.setOnClickListener(new OnClickListener()
        {
@Override
public void onClick(View v)
{
   callstop();
}
});
     
     
     
 
     
     
     
    }

private void callstop()
{

mediaPlayer.stop();
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height)
{

}

@Override
public void surfaceCreated(SurfaceHolder holder)
{
/*try {
mediaPlayer.setDisplay(holder);
} catch (IllegalArgumentException e) {
Log.d("MEDIA_PLAYER", e.getMessage());
} catch (IllegalStateException e) {
Log.d("MEDIA_PLAYER", e.getMessage());
}*/
try {
mediaPlayer.setDisplay(holder);
// if want to play from sd card you can use this code
/ /mediaPlayer.setDataSource("/sdcard/test2.3gp");
Uri myuri = Uri.parse("android.resource://" + getPackageName() + "/"  + R.raw.yourvideofile);
             //make a folder in res which name is raw and put video files //



mediaPlayer.setDataSource(PalyTestActivity.this, myuri);
mediaPlayer.prepare();
mediaPlayer.setVolume(1f, 0.5f);

       mediaPlayer.setScreenOnWhilePlaying(true);
mediaPlayer.start();
int pos = mediaPlayer.getCurrentPosition();
int duration = mediaPlayer.getDuration();

}
catch (IllegalArgumentException e)
{
Log.d("MEDIA_PLAYER", e.getMessage());
}
catch (IllegalStateException e)
{
Log.d("MEDIA_PLAYER", e.getMessage());
}
catch (IOException e)
{
Log.d("MEDIA_PLAYER", e.getMessage());
}

}


@Override
public void surfaceDestroyed(SurfaceHolder holder)
{
mediaPlayer.release();

}
}

=========================================
                                     Main.xml
======================================

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

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

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <Button
            android:id="@+id/stop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="stop" />




        <SurfaceView
            android:id="@+id/surface"
            android:layout_width="fill_parent"
            android:layout_height="209dp" />

    </LinearLayout>

=================================================
//////////////////////////////////////manifest.xml///////////////////////////////////////////
=================================================


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

    <uses-sdk android:minSdkVersion="7" />

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



how can you create table

mainActivity class
=====================


public class main extends Activity
{
TextView textvalue ;
EventDataSQLHelper eventsData;


private static String DB_PATH = "/data/data/com.myandroid.tablecreate/databases/";
private static String DB_NAME = "myDatabase.db";

    /** Called when the activity is first created. */
         String[] roll={"1","2","3"};
    String[] name={"Ram Roy","Shyam Sen ","Samu Rai"};


    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
   
        textvalue = (TextView) findViewById(R.id.textView1);

        eventsData = new EventDataSQLHelper(this, null, null, 1);
       
       if(checkDataBase())
        {
        System.out.println(" \n up on loop......");
        }
     
 for(int i=0;i<roll.length;i++)
        {
        addEvent(name[i],roll[i]);
        }
     
       
        System.out.println(" \n dwon on loop......");
        Cursor cursor = getEvents();
        showEvents(cursor);
       

    }
   
   
   
    private void addEvent(String name,String roll) {
        SQLiteDatabase db = eventsData.getWritableDatabase();
        ContentValues values = new ContentValues();
     //   values.put(EventDataSQLHelper.Name, System.currentTimeMillis());
        values.put(EventDataSQLHelper.Name, name);
       
       
        values.put(EventDataSQLHelper.Roll, roll);
        db.insert(EventDataSQLHelper.TABLE, null, values);

      }
   
    private Cursor getEvents() {
        SQLiteDatabase db = eventsData.getReadableDatabase();
        Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null,
            null, null);
       
        startManagingCursor(cursor);
        return cursor;
      }
   
   
    private void showEvents(Cursor cursor)
    {
   
   
    String Roll1;
   
        StringBuilder ret = new StringBuilder("Saved Events:\n\n");
      while (cursor.moveToNext()) {
       
        System.out.println(" Name = "+cursor.getString(1));
        System.out.println(" Roll = "+cursor.getLong(2));
       
       
          long id = cursor.getLong(0);
         
          String Name1=cursor.getString(1);
          String Roll = cursor.getString(2);
         
          ret.append("id : " + id+ "  Name : "+Name1+"  Roll  :" + Roll + "\n");
         
        }
        textvalue.setText(ret);
       
  /*      cursor.moveToLast();    
        String Name1=cursor.getString(1);
        System.out.println("Name :    "+Name1);  */
       
      }
   
    @Override
    public void onDestroy() {
      eventsData.close();
    }
   
    private boolean checkDataBase() {
SQLiteDatabase checkDB = null;
        try
        {
            String myPath = DB_PATH + DB_NAME;
            checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);
        }catch (Exception e){
            System.out.println("database does't exist yet.");
        }

        if (checkDB != null){
            checkDB.close();
            System.out.println("My db is:- " + checkDB.isOpen());
            return true;
        }
        else        
            return false;      
}
 
}
///////////////////////////////////////////////////////
in this class use getdata() for geting data from the table
and showdata is use for show data from the table

//////////////////////////////////create EventDataSQLHelper .class for create table ////////////////////////
====================================================================



public class EventDataSQLHelper extends SQLiteOpenHelper{

private static final String DATABASE_NAME = "testtable.db";
private static final int DATABASE_VERSION = 1;

// Table name
public static final String TABLE = "mytable";

// Columns
public static final String Name = "Name";
public static final String Roll = "Roll";

public EventDataSQLHelper(Context context, String name,
CursorFactory factory, int version) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);

}

@Override
public void onCreate(SQLiteDatabase db) {

String sql = "create table " + TABLE + "( " + BaseColumns._ID
+ " integer primary key autoincrement, " + Name + " text, "
+ Roll + " text not null);";

Log.d("EventsData", "onCreate: " + sql);
db.execSQL(sql);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {


if (oldVersion >= newVersion)
return;

String sql = null;
if (oldVersion == 1)
sql = "alter table " + TABLE + " add note text;";
if (oldVersion == 2)
sql = "";

Log.d("EventsData", "onUpgrade : " + sql);
if (sql != null)
db.execSQL(sql);

}




   }

///////////desing for main.xml///////////////////////////////////////////
============================================


<?xml version="1.0" encoding="utf-8"?>
<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" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Table Value "
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>




=============================================================
//////////////////////////////////////////////////manifest.xml of this  application ///////////////////////////////////
=============================================================


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

    <uses-sdk android:minSdkVersion="7" />

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







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 ...