Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Monday 26 November 2012

Create user friendly application that show different shapes like circle, square, rectangle, round rectangle, arc, oval in listview and on selecting draw that shape using ShapeDrawable class

Set7Activity.java
package ps.set7;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Set7Activity extends Activity implements OnItemClickListener 
{
 /**
     * www.master-gtu.blogspot.com
     * pankaj sharma (8460479175)
     * vijay chavda  (8460420769) 
     */
 String flags[]={"circle","square","rectangle","round rect","arc","oval"};
 ListView lv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        lv=(ListView) findViewById(R.id.listView1);
        
        ArrayAdapter<String>aa=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,flags);
        lv.setAdapter(aa);
        lv.setOnItemClickListener(this);
    }
 @Override
 public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) 
 {
  Intent i=new Intent(this, screen.class);
  i.putExtra("id", arg2);
  startActivity(i);
 }
}
screen.java
package ps.set7;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
import android.os.Bundle;
import android.view.View;

public class screen extends Activity 
{
 /**
     * www.master-gtu.blogspot.com
     * pankaj sharma (8460479175)
     * vijay chavda  (8460420769) 
     */
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(new screen1(this,getIntent().getIntExtra("id", 0)));
 }
 private class screen1 extends View
 {
  int shape=0;
  public screen1(Context context, int id) {
   super(context);
   shape=id;
  }
  @Override
  protected void onDraw(Canvas canvas) {
   // TODO Auto-generated method stub
   super.onDraw(canvas);
   Shape s=new Shape() {
    
    @Override
    public void draw(Canvas c, Paint paint) 
    {
     paint.setColor(Color.RED);
     if(shape==0)
     {
      c.drawCircle(100, 100, 50, paint);
     }
     else if(shape==1)
     {
      c.drawRect(100, 100, 200, 200,paint);
     }
     else if(shape==2)
     {
      c.drawRect(100, 100, 150, 200, paint);
     }
     else if(shape==3)
     {
      RectF rect=new RectF(100, 100, 150, 200);
      c.drawRoundRect(rect, 5, 5, paint);
     }
     else if(shape==4)
     {
      RectF rect=new RectF(100, 100, 150, 200);
      c.drawArc(rect, 0, 150, true, paint);
     }
     else if(shape==5)
     {
      RectF rect=new RectF(100, 100, 150, 200);
      c.drawOval(rect,paint);
     }
    }
   };
   
   ShapeDrawable obj=new ShapeDrawable();
   obj.setShape(s);
   obj.draw(canvas);
  }
 }
}

Create android application that shows different country flags on listview and on selecting it will show flag of that country

Set6Activity.java
package ps.set6;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;

public class Set6Activity extends Activity implements OnItemClickListener {
    /**
     * www.master-gtu.blogspot.com
     * pankaj sharma (8460479175)
     * vijay chavda  (8460420769) 
     */
 String flags[]={"india","bhutan","nepal","japan"};
 int id[]={R.drawable.india,R.drawable.bhutan,R.drawable.nepal,R.drawable.japan};
 ListView lv;
 ImageView img;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        lv=(ListView) findViewById(R.id.listView1);
        img=(ImageView) findViewById(R.id.imageView1);
        
        ArrayAdapter<String>aa=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,flags);
        lv.setAdapter(aa);
        lv.setOnItemClickListener(this);
    }
 @Override
 public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) 
 {
  img.setImageResource(id[arg2]);
 }
}

Sunday 18 November 2012

Write a Script for Simple Database Management System Operation


clear
echo "\nDATABASE MANAGEMENT SYSTEM OPERATION\n"
echo "-----------------------------------------"
echo "1. VIEW RECORD BASES ON QUERY"
echo "2. ADD RECORD"
echo "3. DELETE RECORD"
echo "4. COUNT TOTAL NUMBER OF RECORD"
echo "5. EXIT"
echo "Enter your choice"
read ch
case $ch in
1)
echo " * Serching Record * "
echo "1. EMP_NO"
echo "2. EMP_NAME"
echo "3. EMP_ADDRESS"
echo "4. EMP_AGE"
echo "5. EMP_GENDER"
echo "6. EMP_DESIGNATION"
echo "7. EMP_BASIC_SALARY"
read serch_choice
case $serch_choice in
1)
echo "Enter Employee NO "
read empno
empno=`expr $empno + 1`

head -$empno emp.txt > temp1

tail -1 temp1 > temp2
no= `awk '{print $1}' temp2`
echo $no
;;
2)
echo "Enter Employee's Name"
read empname
grep "$empname" emp.txt
;;
3)
echo "Enter Address"
read empadd
grep "$empadd" emp.txt
;;
4)
echo "Enter Age"
read age
grep "$age" emp.txt
;;
5)
echo "Enter Gender"
read gender
grep "$gender" emp.txt
;;
6)
echo "Enter Designation"
read empdesig
grep "$empdesig" emp.txt
;;

7)
echo "Enter Basic Salary"
read bs
grep "$bs" emp.txt
;;
8)
echo "wrong choice"
;;
esac
;;
2)
echo "Enter emp_no : "
read empno
echo "Enter emp_name : "
read empname
echo "Enter address : "
read empadd
echo "Enter age : "
read age
echo "Enter Gender : "
read gender
echo "Enter designation : "
read empdesig
echo "Enter basic salary : "
read bs
record="$empno|$empname|$empaddr|$age|$gender|$empdesig|$bs"
`echo $record>>emp.txt`
echo " \t Record insert successfully..."
;;
3)
echo "Enter name"
read name
#`sed "/$name/d" emp.txt>tempfile1`
`grep -w "/$name/d" emp.txt>tempfile1`
`cat tempfile1>emp.txt`
rm tempfile1
  echo "\t Record delete successfully..."
;;
4) echo "Enter name"
read name
`sed "/$name/d" emp.txt>tempfile1`
`cat tempfile1>emp.txt`
rm tempfile1
echo "Enter emp_no : "
read empno
echo "Enter emp_name : "
read empname
echo "Enter address : "
read empadd
echo "Enter age : "
read age
echo "Enter Gender : "
read gender
echo "Enter designation : "
read empdesig
echo "Enter basic salary : "
read bs
record="$empno|$empname|$empaddr|$age|$gender|$empdesig|$bs"
`echo $record>>emp.txt`
echo " \t Record modify successfully..."
;;
Esac

Wednesday 14 November 2012

Simple Gallery View Example in android

Demo18Activity.java
package ps.demo18;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;

public class Demo18Activity extends Activity implements OnItemClickListener {
    /** 
     * www.master-gtu.blogspot.com
     * pankaj sharma(8460479175), 
     * chavda vijay(8460420769) 
     */
 Gallery gv;
 int images[]={R.drawable.photo1,R.drawable.photo2,R.drawable.photo3,R.drawable.photo4};
 ImageView img;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        gv=(Gallery) findViewById(R.id.gallery1);
        
        img=(ImageView) findViewById(R.id.imageView1);
        
        gv.setAdapter(new arrayAdapter(this));
        
        gv.setOnItemClickListener(this);
    }
    private class arrayAdapter extends BaseAdapter
    {
     int images[]={R.drawable.photo1,R.drawable.photo2,R.drawable.photo3,R.drawable.photo4};
     Context c;
     public arrayAdapter(Context context)
     {
      c=context;
     }
  @Override
  public int getCount() {
   // TODO Auto-generated method stub
   return images.length;
  }

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

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

  @Override
  public View getView(int arg0, View arg1, ViewGroup arg2) {
   // TODO Auto-generated method stub
   
   ImageView img = new ImageView(c);
   img.setImageResource(images[arg0]);
   img.setLayoutParams(new Gallery.LayoutParams(100, 200));
   
   return img;
  }
    }
 @Override
 public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
  // TODO Auto-generated method stub

  img.setImageResource(images[arg2]);
  Toast.makeText(this, images[arg2]+" selected", 1).show();
 }
}

Wednesday 7 November 2012

Literature Survey & Acknowledgement


Acknowledgement

There are a number of people whom I would like to thank for their help and support in the creation of this dissertation!

I would like to thank the lecturers and staff of JVIMS for their support, guidance and patience but especially Prof. Apexa Joshi for her support as thesis advisor. Her encouragement at all stages of this project work has been contributed greatly to present the contents of the project.

We are grateful to Prof. Apexa Joshi, Seema Makhecha(H.O.D), Dr. K.J.Thankanchand Director of JVIMS M.C.A. College, for allowing us to carry out our dissertation work.

We would also like to thank all the staff members of the computer department, college library which provided us lot of valuable information regarding our project and for their understanding
whenever I required time to study or research. Last but not the least; we are obliged to our parents & all those who have directly or indirectly helped us to make this dissertation happen.


Literature survey


  1. How does a webmaster ensure that they appear high on search results? The answer is SEO(search engine optimization). Jerri Ledford (2008) defines the term SEO as “Improving a web site in an attempt to attract search engine crawlers”. A crawler is a piece of software that selects websites and indexes their contents for the purposes of building a search database.
  2. SEO is not a new idea; it has been around nearly as long as the search engines. However with the massive increase in traffic and usage on the internet, it has become a hugely important part of the design process. We use various techniques like keyword research, link building etc.
  3. This dissertation sets out to determine and document the main search engine optimization techniques used today i.e. Keyword research which is most important. The final part of the dissertation will apply all this to techniques to website for optimizing our site in search engine ranking.


Friday 26 October 2012

Create an application to open any URL inside the application and clicking on any link from that URl should not open Native browser but that URL should open the same screen.

Note:Give "INTERNET" permission in android Manifest file.
WebViewActivity.java
package ps.webview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class WebviewActivity extends Activity implements OnClickListener 
{
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */

//CREATE WEBVIEW OBJECT
 WebView web;
 TextView edurl;
 Button btgo;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        // INTIALIZE WEBVIEW OBJECT
        // GIVE PERMISSION INTERNET IN ANDROIDMAINFEST FILE
        
        web=(WebView) findViewById(R.id.webView1);
        edurl=(TextView) findViewById(R.id.editTexturl);
        btgo=(Button) findViewById(R.id.buttongo);
        
        btgo.setOnClickListener(this);
    }
 @Override
 public void onClick(View arg0) {
  // TODO Auto-generated method stub
  if(edurl.getText().toString().equals(""))
  {
   Toast.makeText(this, "Pls Enter URL...", 1).show();
  }
  else 
  {
   String stringurl=edurl.getText().toString();
   
   if(!stringurl.startsWith("http://") &amp;&amp;  !stringurl.startsWith("https://") )
    stringurl="http://"+stringurl;
   
   //ENABELING JAVA SCRIPT ON WEBVIEW
   web.getSettings().setJavaScriptEnabled(true);
   
   //LOAD URL ON WEBVIEW
   web.loadUrl(stringurl);

   //SETTING WEBVIEW CLIENT TO OPEN IN SAME SCREEN NOT ON NATIVE BROWSER
   web.setWebViewClient(new WebViewClient());
  }
 }
}

Friday 19 October 2012

Simple Database Operation Example In Android

QUESTION
 Develop an android application for student marks sheet
   a. create student database on SDcard
   b. create table
    i.  student { sno, name, dob }
    ii. marks { sno, s1, s2, s3 }
   c. action to be performed
    i.   Add record
    check for duplication
    ii.  View record
    sno, name, total, per, grade
    iii. Search record
    search by no and name
    iv.  Delete record
 
   With Proper Validation

DatabaseActivity.java
package ps.database;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class DatabaseActivity extends Activity implements OnItemClickListener, TextWatcher {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 ListView lv;
 SQLiteDatabase db;
 TextView edsearchbyno;
 
  String names[];
 TextView edsearchbyname;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        db=openOrCreateDatabase("/sdcard/database", SQLiteDatabase.CREATE_IF_NECESSARY, null);
        db.execSQL("create table if not exists student(sno text, name text, dob text)");
        db.execSQL("create table if not exists marks(sno text, s1 text, s2 text, s3 text)");
        lv=(ListView) findViewById(R.id.listView1);
        
        Cursor cur=db.rawQuery("select * from student", null);
names=new String[cur.getCount()];
for(int i=0;i<cur.getCount();i++)
{
 cur.moveToNext();
 names[i]=cur.getstring(0)+". "+cur.getString(1);
}
ArrayAdapter<"String">arr=new ArrayAdapter<string>(this, android.R.layout.simple_list_item_1,names);
lv.setAdapter(arr);
lv.setOnItemClickListener(this);
        
        //===============================
        
        edsearchbyname=(TextView) findViewById(R.id.editTextsearchname);
        
        edsearchbyname.addTextChangedListener(this);
        
        //===============================
    }
 @Override
 public void onItemClick(AdapterView arg0, View arg1, int pos, long arg3) {
  // TODO Auto-generated method stub
  Intent myintent =new Intent(this,view.class);
  myintent.putExtra("pos", names[pos].substring(0, names[pos].indexOf('.'))+"");
  Toast.makeText(this,names[pos].substring(0, names[pos].indexOf('.'))+" ",1).show();
  startActivity(myintent);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // TODO Auto-generated method stub
  super.onCreateOptionsMenu(menu);
  menu.add(0,0,0,"INSERT");
  menu.add(0,1,1,"REFERESH");
  return true;
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  // TODO Auto-generated method stub
  super.onOptionsItemSelected(item);
  if(item.getItemId()==0)
  {
   
   startActivity(new Intent(this,insert.class));
  }
  else if(item.getItemId()==1)
  {
   
   startActivity(new Intent(this,DatabaseActivity.class));
  }
  return true;
 }
 //======================searching===========================
 @Override
 public void afterTextChanged(Editable arg0) {
  // TODO Auto-generated method stub
  Cursor cur=db.rawQuery("select * from student where name like '%"+edsearchbyname.getText().toString()+"%'", null);
  if(cur.getCount()>0)
  {
   names=new String[cur.getCount()];
names=new String[cur.getCount()];
for(int i=0;i<cur.getCount();i++)
{
 cur.moveToNext();
 names[i]=cur.getstring(0)+". "+cur.getString(1);
}
ArrayAdapter<"String">arr=new ArrayAdapter<string>(this, android.R.layout.simple_list_item_1,names);
lv.setAdapter(arr);
lv.setOnItemClickListener(this);
   lv.setAdapter(arr);
  }
 }
 @Override
 public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
   int arg3) {
  // TODO Auto-generated method stub
  
 }
 @Override
 public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
  // TODO Auto-generated method stub
  
 }
}

view.java
package ps.database;

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class view extends Activity implements OnClickListener
{
 EditText edno,edname,edtotal,edper,edgrade;
 Button btdelete;
 SQLiteDatabase db;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.view);
  
  db=openOrCreateDatabase("/sdcard/database", SQLiteDatabase.CREATE_IF_NECESSARY, null);
  edno=(EditText) findViewById(R.id.editTextviewnumber);
  edname=(EditText) findViewById(R.id.editTextviewname);
  edtotal=(EditText) findViewById(R.id.editTexttotal);
  edper=(EditText) findViewById(R.id.editTextper);
  edgrade=(EditText) findViewById(R.id.editTextgrade);
  
  btdelete=(Button) findViewById(R.id.buttondelete);
 
  String pos=getIntent().getStringExtra("pos");
  
  Cursor cur=db.rawQuery("select * from student where sno='"+pos+"'", null);
  
  cur.moveToNext();
  
  edno.setText(cur.getString(0));
  edname.setText(cur.getString(1));
  cur.close();
  
  cur=db.rawQuery("select * from marks where sno='"+edno.getText().toString()+"'", null);
  cur.moveToNext();
  int total=Integer.parseInt(cur.getString(1)+"") +Integer.parseInt(cur.getString(2)+"") +Integer.parseInt(cur.getString(3)+"");
  edtotal.setText(total+"");
  int per=total/3;
  edper.setText(total/3+"");
  if(per>65)
   edgrade.setText("A");
  else if(per<=65)
   edgrade.setText("B");

  edno.setEnabled(false);
  edname.setEnabled(false);
  edtotal.setEnabled(false);
  edper.setEnabled(false);
  edgrade.setEnabled(false);
  
  
  btdelete.setOnClickListener(this);
 }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(btdelete.getId()==v.getId())
  {
   try
   {
   db.execSQL("delete from student where sno='"+edno.getText().toString()+"'");
   db.execSQL("delete from marks where sno='"+edno.getText().toString()+"'");
   Toast.makeText(this, "Delete Success",1).show();
   }
   catch(Exception e)
   {
    Toast.makeText(this, e.toString(), 1).show();
   }
  }
 }
}
insert.java
package ps.database;

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class insert extends Activity implements OnClickListener 
{
 EditText edsno,edname,eddob,eds1,eds2,eds3;
 Button btsave,btclear;
 SQLiteDatabase db;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.insert);
  
  db=openOrCreateDatabase("/sdcard/database", SQLiteDatabase.CREATE_IF_NECESSARY, null);
  edsno=(EditText) findViewById(R.id.editTextinsertnumber);
  edname=(EditText) findViewById(R.id.editTextinsertname);
  eddob=(EditText) findViewById(R.id.editTextinsertdob);
  eds1=(EditText) findViewById(R.id.editTextinserts1);
  eds2=(EditText) findViewById(R.id.editTextinserts2);
  eds3=(EditText) findViewById(R.id.editTextinserts3);
  btsave=(Button) findViewById(R.id.buttoninsertsave);
  btclear=(Button) findViewById(R.id.buttoninsertclear);
  
  btsave.setOnClickListener(this);
  btclear.setOnClickListener(this);

 }

 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(btsave.getId()==v.getId())
  {
   Cursor cur=db.rawQuery("select * from student where sno='"+edsno.getText().toString()+"'", null);
   
   if(cur.getCount()>0)
   {
    Toast.makeText(this, "aleready exists..",1).show(); 
   }
   else 
   {
    if(edsno.getText().toString().equals("") || edname.getText().toString().equals("") || eddob.getText().toString().equals("") ||eds1.getText().toString().equals("")  || eds2.getText().toString().equals("") ||eds3.getText().toString().equals("") )
    {
     Toast.makeText(this, "Pls Enter All the fields", 1).show(); 
    }
    else 
    {
     db.execSQL("insert into student values('"+edsno.getText().toString()+"','"+edname.getText().toString()+"','"+eddob.getText().toString()+"')");
     db.execSQL("insert into marks values('"+edsno.getText().toString()+"','"+eds1.getText().toString()+"','"+eds2.getText().toString()+"','"+eds3.getText().toString()+"')");
    }

    Toast.makeText(this,"Insert success...", 1).show();
   }
  }
  else if(btclear.getId()==v.getId())
  {
   edsno.setText("");
   edname.setText("");
   eddob.setText("");
   eds1.setText("");
   eds2.setText("");
   eds3.setText("");
  }
 }
}

Thursday 18 October 2012

Create an application to pick up any image from the native application gallery and display it on the screen.

Pro23Activity.java
Note :  Drop Images on Sdcard then go to menus open "Dev-Tools" -> "Media Scanner"
package ps.pro23;

import android.app.Activity;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

public class Pro23Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 
 ImageView img;
 Button btnext, btprevious;
 Cursor cur;
 int total,current;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        img=(ImageView) findViewById(R.id.imageView1);
        btnext=(Button) findViewById(R.id.buttonnext);
        btprevious=(Button) findViewById(R.id.buttonprevious);
        btprevious.setEnabled(false);
        
        btnext.setOnClickListener(this);
        btprevious.setOnClickListener(this);

//Note Media Class is inside MediaStore.Images for images [see 8th line]
        
        //Uri umedia=Uri.parse(Media.EXTERNAL_CONTENT_URI);
        Uri umedia=Uri.parse("content://media/external/images/media");
        
        cur=managedQuery(umedia, null, null,null,null);
        total=cur.getCount();
        
        current=1;
        cur.moveToNext();
        img.setImageBitmap(BitmapFactory.decodeFile(cur.getString(1)));       
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(v.getId()==btnext.getId())
  {
   current++;
   cur.moveToNext();
   img.setImageBitmap(BitmapFactory.decodeFile(cur.getString(1)));
   if(current==total)
   {
    btnext.setEnabled(false);
   }
   btprevious.setEnabled(true);
  }
  else if(v.getId()==btprevious.getId())
  {
   current--;
   cur.moveToPrevious();
   img.setImageBitmap(BitmapFactory.decodeFile(cur.getString(1)));
   if(current==1)
   {
    btprevious.setEnabled(false);
   }
   btnext.setEnabled(true);
  }
 }
}

Create an application to take picture using native application.

Pro22Activity.java
Note: Give permission in manifest file as "android.permission.CAMERA"
package ps.pro22;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class Pro22Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 
 ImageView img;
 Button btcapture;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        img=(ImageView) findViewById(R.id.imageView1);
        btcapture=(Button) findViewById(R.id.buttoncapture);
        
        btcapture.setOnClickListener(this);
    }
    @Override
 public void onClick(View arg0) {
  // TODO Auto-generated method stub
  Intent myintent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  startActivityForResult(myintent, 0);
 }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     // TODO Auto-generated method stub
     super.onActivityResult(requestCode, resultCode, data);
     Bitmap myimage=(Bitmap) data.getExtras().get("data");
     img.setImageBitmap(myimage);
    }
}

Create an application to send message between two emulators.

Pro21Activity.java
package ps.pro21;

import android.app.Activity;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Pro21Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 EditText ednumber, edmsg;
 Button btsend;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ednumber=(EditText) findViewById(R.id.editTextnumber);
        edmsg=(EditText) findViewById(R.id.EditTextmsg);
        btsend=(Button) findViewById(R.id.buttonsend);
        
        btsend.setOnClickListener(this);
    }
    private void sendsms(String num,String msg)
    {
     SmsManager sms=SmsManager.getDefault();
     sms.sendTextMessage(num, null, msg, null, null);
    }
 @Override
 public void onClick(View arg0) {
  // TODO Auto-generated method stub
  sendsms(ednumber.getText().toString(),edmsg.getText().toString());;
 }
}

Create an application to draw line on the screen as user drag his finger.

Pro20Activity.java
package ps.pro20;

import android.app.Activity;
import android.os.Bundle;
public class Pro20Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new ScreenActivity(this));
    }
}
ScreenActivity.java
package ps.pro20;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.MotionEvent;
import android.view.View;
public class ScreenActivity extends View 
{
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Paint paintBrush=new Paint(Paint.ANTI_ALIAS_FLAG);
 Path path=new Path();
 
 public ScreenActivity(Context context) {
  super(context);  
  paintBrush.setColor(Color.RED);
  paintBrush.setStrokeWidth(5);
  paintBrush.setStyle(Paint.Style.STROKE);
 }
 @Override
 protected void onDraw(Canvas canvas) {
  // TODO Auto-generated method stub
 super.onDraw(canvas);
  canvas.drawPath(path, paintBrush);
 }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
  // TODO Auto-generated method stub
  super.onTouchEvent(event);
  
  //------getting position-------
  
  float x=event.getX();
  float y=event.getY();
  
  switch(event.getAction())
  {
   case MotionEvent.ACTION_DOWN:
    path.moveTo(x, y);
    return true;
    
   case MotionEvent.ACTION_MOVE:
    path.lineTo(x, y);
    break;
  }
  invalidate();
  return true; 
 }
}

Create an application to read file from the sdcard and display that file content to the screen.

Pro19Activity.java
package ps.pro19;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class Pro19Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 TextView tvcontent;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
        tvcontent=(TextView) findViewById(R.id.textView2);
        
        try
        {
         File myFile=new File("/sdcard/hello.txt");
         InputStream in=null;
         in=new FileInputStream(myFile);
         
         String msg="";
         while(in.available()>0)
         {
          msg=msg+(char)in.read();
         }
         in.close();
         tvcontent.setText(msg);

        }
        catch(Exception e)
        {
         Toast.makeText(this, e.toString(),Toast.LENGTH_LONG).show();
        }
    }
}

Create an application to make Insert , update , Delete and retrieve operation on the database.

DataBaseActivity.java
package vc.dataBase;

import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class DataBaseActivity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 SQLiteDatabase db;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       // db.openDatabase("Data1",SQLiteDatabase.CREATE_IF_NECESSARY,null);
        db=openOrCreateDatabase("Data1",SQLiteDatabase.CREATE_IF_NECESSARY,null);
        db.execSQL("create table if not exists student(id integer primary key, name text not null,age integer not null,phone text not null)");
    }
    public boolean onCreateOptionsMenu(Menu menu)
    {
     
     super.onCreateOptionsMenu(menu);
     //When You are put icon in Menu then create the Menu item object
     
     menu.add(0,0,0,"Insert");
     menu.add(0,1,0,"Update");
     menu.add(0,2,0,"Delete");
     menu.add(0,3,0,"View");
  return true;
     
    }
    public boolean onOptionsItemSelected(MenuItem item)
    {
     super.onOptionsItemSelected(item);
     Intent myIntent=new Intent(this,InsertActivity.class);
  myIntent.putExtra("label",item.getItemId());
     if(item.getItemId()==0)
     {
   this.startActivity(myIntent);
     }
     else if(item.getItemId()==1)
     {
      this.startActivity(myIntent);
     }
     else if(item.getItemId()==2)
     {
      this.startActivity(myIntent);
     }
     else if(item.getItemId()==3)
     {
      this.startActivity(myIntent);
     }
     
  return true;
     
    }
}
InsertActivity.java
package vc.dataBase;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class InsertActivity extends Activity implements OnClickListener, TextWatcher, OnItemClickListener {
    /** Called when the activity is first created. */
 //Control Declaration
 EditText txtname,txtage,txtphone;
 Button btnSubmit,btnClear;
 TextView lblname,lblage,lblphone,lblmsg;
 ListView list;
 
 //Variable Declaration
 boolean duplicate=true;
 int flag,len=0,count=0;
 String record[];
 String sname;
 
 //DataBase Object Declaration
 SQLiteDatabase db;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.insert);
        db=openOrCreateDatabase("Data",SQLiteDatabase.CREATE_IF_NECESSARY,null);
        
        txtname=(EditText) findViewById(R.id.txtname);
        txtage=(EditText) findViewById(R.id.txtage);
        txtphone=(EditText) findViewById(R.id.txtphone);
        
        lblname=(TextView) findViewById(R.id.lblname);
        lblage=(TextView) findViewById(R.id.lblage);
        lblphone=(TextView) findViewById(R.id.lblphone);
        lblmsg=(TextView) findViewById(R.id.lblmsg);
        list=(ListView) findViewById(R.id.list);
        list.setOnItemClickListener(this);
        
        btnSubmit=(Button) findViewById(R.id.btnSumit);
        btnClear=(Button) findViewById(R.id.btnClear);
        
        Intent intent=getIntent();
  flag=intent.getIntExtra("label", 0);
  
     btnSubmit.setOnClickListener(this);
     btnClear.setOnClickListener(this);
     txtname.requestFocus();
     list.setVisibility(-1);
     lblmsg.setVisibility(-1);
  
     if(flag==1)
  {
   invisible();
   txtname.addTextChangedListener(this);
   btnSubmit.setText("Edit");
   btnClear.setText("Cancel");
   list.setVisibility(0);
  }
  else if(flag==2)
  {
   invisible();
   txtname.addTextChangedListener(this);
   btnSubmit.setText("Delete");
   btnClear.setText("Cancel");
   list.setVisibility(0);
  }
  else if(flag==3)
  {
   View_Records();
  }
     }
    //Method Declaration
    public void invisible()
 {
     lblage.setVisibility(-1);
  lblphone.setVisibility(-1);
  txtage.setVisibility(-1);
  txtphone.setVisibility(-1);
  btnSubmit.setVisibility(-1);
  btnClear.setVisibility(-1);
 }
    public void visible()
    {
     lblage.setVisibility(0);
  lblphone.setVisibility(0);
  txtage.setVisibility(0);
  txtphone.setVisibility(0);
  btnSubmit.setVisibility(0);
  btnClear.setVisibility(0);
 }
    public void DisEnable()
    {
     txtname.setEnabled(false);
     txtage.setEnabled(false);
     txtphone.setEnabled(false);
    }
    public void Enable()
    {
     txtname.setEnabled(true);
     txtage.setEnabled(true);
     txtphone.setEnabled(true);
    }
    public void clear()
 {
  txtname.setText("");
  txtage.setText("");
  txtphone.setText("");
  txtname.requestFocus();
 }
    public void View_Records()
    {
     list.setVisibility(0);
     lblmsg.setVisibility(0);
     invisible();
     txtname.setVisibility(-1);
     lblname.setVisibility(-1);
     
     int i=0;
     Cursor cur=db.rawQuery("select *from Student",null);
     len=cur.getCount();
     record=new String[len];
     if(len>0)
  {
   while(cur.moveToNext())
   {
    record[i]=cur.getString(0)+"  |  "+cur.getString(1)+"  |  "+cur.getString(3);
    i++;
   }
  }
     
     ArrayAdapter<String> arr=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,record);
     list.setAdapter(arr);
    }
    //Control Method
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  Button action=(Button) v;
  duplicate=true;
  if(action.getText().toString().equals("Submit")) //Record Insert
  {   
   if((txtname.getText().toString().equals(""))&&(txtage.getText().toString().equals(""))&&(txtphone.getText().toString().equals("")))
   {
    Toast.makeText(this,"Record is Already Empty",Toast.LENGTH_SHORT).show();
   }
   else if((txtname.getText().toString().equals("")))
   {
    Toast.makeText(this,"Please Enter Name",Toast.LENGTH_SHORT).show();
   }
   else if((txtage.getText().toString().equals("")))
   {
    Toast.makeText(this,"Please Enter Age",Toast.LENGTH_SHORT).show();
   }
   else if((txtphone.getText().toString().equals("")))
   {
    Toast.makeText(this,"Please Enter Phone Number",Toast.LENGTH_SHORT).show();
   }
   else //Duplicate Record
   {
    String name=txtname.getText().toString();
    String phone=txtphone.getText().toString();
    Cursor c;
    if((c=db.rawQuery("select *from Student where name='"+name+"'", null))!=null)
    {
     if(c.getCount()>0)
     {
      duplicate=false;
      Toast.makeText(this,"Name Already Exist ",Toast.LENGTH_SHORT).show();
     }
    }
    if((c=db.rawQuery("select *from Student where phone='"+phone+"'", null))!=null)
    {
     if(c.getCount()>0)
     {
      duplicate=false;
      Toast.makeText(this,"Number Already Exist ",Toast.LENGTH_SHORT).show();
     }
    }
    if(duplicate==true)
    {
     int age=Integer.parseInt(txtage.getText().toString());
     db.execSQL("insert into Student(name,age,phone)values('"+name+"',"+age+",'"+phone+"')");
     clear();
     Toast.makeText(this,"Record Add SuccessFully",Toast.LENGTH_SHORT).show();
    }
    
   }
  }
  else if(action.getText().toString().equals("Clear")) //Clear Field
  {
   if(!((txtname.getText().toString().equals(""))&&(txtage.getText().toString().equals(""))&&(txtphone.getText().toString().equals(""))))
   {
    clear();
   }
   else
   {
    Toast.makeText(this,"Record is Already Empty",Toast.LENGTH_SHORT).show();
   }
  }
  else if(action.getText().toString().equals("Edit")) //Edit Record
  {
   Enable();
   btnSubmit.setText("Save");
  }
  else if(action.getText().toString().equals("Save")) //After Edit Record or Check Duplicate Record 
  {
   String name=txtname.getText().toString();
   String phone=txtphone.getText().toString();
   Cursor c;
   if((c=db.rawQuery("select *from Student where name='"+name+"'and phone='"+phone+"'", null))!=null)
   {
    if(c.getCount()>0)
    {
     duplicate=false;
     Toast.makeText(this,"Duplicate Name Not Allow ",Toast.LENGTH_SHORT).show();
    }
   }
   else if((c=db.rawQuery("select *from Student where phone='"+phone+"'and name!='"+name+"'", null))!=null)
   {
    if(c.getCount()>0)
    {
     duplicate=false;
     Toast.makeText(this,"Duplicate Number Not Allow ",Toast.LENGTH_SHORT).show();
    }
   }
   if(duplicate==true)
   {
    int age=Integer.parseInt(txtage.getText().toString());
    db.execSQL("update Student set name='"+name+"',age="+age+",phone='"+phone+"' where name='"+sname+"';");
    Toast.makeText(this,"Record Update Successfully",Toast.LENGTH_SHORT).show();
    btnSubmit.setText("Submit");
    this.startActivity(new Intent(this,DataBaseActivity.class));
   }
  }
  else if(action.getText().toString().equals("Cancel")) //Cancel Record and Move First Screen
  {
   this.startActivity(new Intent(this,DataBaseActivity.class));
  }
  else if(action.getText().toString().equals("Delete")) //Delete Particular Record
  {
   String name=txtname.getText().toString();
   db.execSQL("delete from Student where name='"+name+"';");
   Toast.makeText(this,"Delete Record Successfully",Toast.LENGTH_SHORT).show();
   this.startActivity(new Intent(this,DataBaseActivity.class));
  }
 }
 //Edit Text Method
 @Override
 public void afterTextChanged(Editable arg0) { //Filtering the Record
  // TODO Auto-generated method stub
  String name=txtname.getText().toString();
  Cursor cur=db.rawQuery("select *from Student where name LIKE '"+name+"%'", null);
  len=cur.getCount();
  if(txtname.getText().toString().equals(""))
  {
   Toast.makeText(this,"Enter Name"+count,Toast.LENGTH_SHORT).show();
   list.setAdapter(null);
   for(int i=0; i<count; i++)
    record[i]="";
  }
  else if(len>0)
  {
   if(txtname.getText().toString().equals(""))
   {
    list.setAdapter(null);
    for(int i=0; i<count; i++)
     record[i]="";
   }
   else if(len>0)
   {
    record=new String[len];
    cur.moveToNext();
    count=len;
    for(int i=0; i<len; i++)
    {
     record[i]=cur.getString(1);
     cur.moveToNext();
    }
   }
   ArrayAdapter<String> arr =new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,record);
   list.setAdapter(arr);
 }
 else
 {
  Toast.makeText(this,"Record Not Found",Toast.LENGTH_SHORT).show();
 }
 }
 @Override
 public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
   int arg3) {
  // TODO Auto-generated method stub
 }
 @Override
 public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
  // TODO Auto-generated method stub
 }
 @Override
 public void onItemClick(AdapterView<?> p, View v, int pos, long s) {
  // TODO Auto-generated method stub
  list.setVisibility(-1);
  visible();
  sname=record[pos];
  Cursor c=db.rawQuery("select *from Student",null);
  int len1=c.getCount();
  if(len1>0)
  {
   while(c.moveToNext())
   {
    if(sname.equals(c.getString(1)))
    {
     txtname.setText(c.getString(1));
     txtage.setText(c.getInt(2)+"");
     txtphone.setText(c.getString(3));
     break;
    }
    DisEnable();
    list.setVisibility(-1);
   }
  }
 }
}

Create an application that will play a media file from the memory card.

PRO17Activity.java
Note :  Drop Audios on Sdcard then go to menus open "Dev-Tools" -> "Media Scanner"
package vc.PRO17;

import android.app.Activity;
import android.database.Cursor;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.provider.MediaStore.Audio.Media;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class PRO17Activity extends Activity implements OnClickListener, OnItemClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Button btnpre,btnstart,btnnext;
 String song[];
 MediaPlayer player;
 ListView lv;
 boolean flag=false;
 static int j=0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btnpre=(Button) findViewById(R.id.btnpre);
        btnstart=(Button) findViewById(R.id.btnstart);
        btnnext=(Button) findViewById(R.id.btnnext);
        lv=(ListView) findViewById(R.id.list);
        
        btnpre.setOnClickListener(this);
        btnstart.setOnClickListener(this);
        btnnext.setOnClickListener(this);
        lv.setOnItemClickListener(this);
        btnpre.setTextColor(Color.GREEN);
        btnstart.setTextColor(Color.GREEN);
        btnnext.setTextColor(Color.GREEN);
        try
        {
         Cursor cur=managedQuery(Media.EXTERNAL_CONTENT_URI, null, null, null, null);
         song=new String[cur.getCount()];
         int i=0;
         while(cur.moveToNext())
         {
          song[i]=cur.getString(1).substring(12);
          i++;
         }
         ArrayAdapter aa=new ArrayAdapter(this,android.R.layout.simple_list_item_1,song);
         lv.setAdapter(aa);
        }
        catch(Exception e)
        {
         Toast.makeText(this,e.toString(),1).show();
        }
    }
    public void song_play()
    {
     try
     {
      if(flag==true)
       player.stop();
      player=new MediaPlayer();
   player.setDataSource("/sdcard/"+song[j]);
      player.prepare();
   player.start();
   flag=true;
  }
     catch(Exception e)
  {
   Toast.makeText(this,"Play"+j, 1).show();
  }
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  Button action =(Button) v;
  if(v.getId()==btnpre.getId())
  {
   if(j>0)
   {
    j--;
    song_play();
   }
   else
   {
    song_play();
   }
   
  }
  else if(action.getText().toString().equals("|>"))
  {
   song_play();
   btnstart.setBackgroundResource(R.drawable.pause);
   btnstart.setText("||");
  }
  else if(action.getText().toString().equals("||"))
  {
   player.stop();
   btnstart.setBackgroundResource(R.drawable.play);
   btnstart.setText("|>");
  }
  else if(v.getId()==btnnext.getId())
  {
   if(song.length-1>j)
   {
    j++;
    song_play();
   }
   else
   {
    song_play();
   }
  }
 }
 @Override
 public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
  // TODO Auto-generated method stub
  j=arg2;
  song_play();
  btnstart.setText("||");
  btnstart.setBackgroundResource(R.drawable.pause);
 }
}

Create an application to read file from asset folder and copy it in memory card.

Pro16Activity.java
package ps.pro16;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class Pro16Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 TextView tvmsgfromasset,tvmsgfromsdcard;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        try 
        {
         tvmsgfromasset=(TextView) findViewById(R.id.textView2);
            tvmsgfromsdcard=(TextView) findViewById(R.id.textView4);
            
   //--------reading from asset folder-----------
         
         InputStream is1=null;     
   is1=getResources().getAssets().open("hello.txt");
   
   if(is1!=null)
   {

    Toast.makeText(this, "File Exists", Toast.LENGTH_LONG).show();
    
    String myMsg1="";
    while(is1.available()>0)
    {
     myMsg1=myMsg1+(char)is1.read();
    }
    is1.close();
    
    tvmsgfromasset.setText(myMsg1);
    
   //--------writing to sdcard-----------
    
    byte b[]=myMsg1.getBytes();
    File myFile = new File("/sdcard/hello.txt");
    OutputStream os=new FileOutputStream(myFile);
    os.write(b);
    os.close();
    Toast.makeText(this, "write Success.", Toast.LENGTH_LONG).show();
    
   //--------read file from sdcard--------
    
    InputStream is2=null;
    is2=new FileInputStream(myFile);
    String myMsg2="";
    while(is2.available()>0)
    {
     myMsg2=myMsg2+(char)is2.read();
    }
    is2.close();
    tvmsgfromsdcard.setText(myMsg2+"");
   }
  } 
        catch (IOException e) 
        {
   Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
  }
    }
}

Create an application that will create database with table of User credential.

PRO15Activity.java
package vc.PRO15;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class PRO15Activity extends Activity implements OnItemClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 SQLiteDatabase db;
 ListView lv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        db=openOrCreateDatabase("database1",SQLiteDatabase.CREATE_IF_NECESSARY, null);
  db.execSQL("create table if not exists stud(id integer primary key AUTOINCREMENT,name text,age integer)");
  lv =(ListView) findViewById(R.id.list);
  lv.setOnItemClickListener(this);
  Cursor cur=db.query("stud",null, null, null, null, null, null);
  
  if(cur.getCount()>0)
  {
   String name[]=new String[cur.getCount()];
   int i=0;
   while(cur.moveToNext())
   {
    name[i++]=cur.getString(1);
   }
   ArrayAdapter aa=new ArrayAdapter(this,android.R.layout.simple_list_item_1,name);
   lv.setAdapter(aa);
  }
  else
  {
         Toast.makeText(this,"DataBase is Empty...", 1000).show();
  }
    }
 @Override
 public void onItemClick(AdapterView p, View v, int pos, long c) {
  // TODO Auto-generated method stub
  Intent myintent=new Intent(this,update.class);
  TextView iname=(TextView) v;
  myintent.putExtra("label",iname.getText().toString() );
  startActivity(myintent);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // TODO Auto-generated method stub
  super.onCreateOptionsMenu(menu);
  menu.add(0,5,0,"Insert");
  menu.add(0,1,0,"Update");
  menu.add(0,2,0,"Delete");
  return true;
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  // TODO Auto-generated method stub
   super.onOptionsItemSelected(item);
   if(item.getItemId()==5)
   {
    Intent myintent=new Intent(this,update.class);
    myintent.putExtra("flag",item.getItemId());
    startActivity(myintent);
   } 
   else if(item.getItemId()==1)
   {
    Intent myintent=new Intent(this,update.class);
    myintent.putExtra("flag",item.getItemId());
    startActivity(myintent);
   }
   else  if(item.getItemId()==2)
   {
    Intent myintent=new Intent(this,update.class);
    myintent.putExtra("flag",item.getItemId());
    startActivity(myintent);
   }
   return true;
 }
}
insert.java
package vc.PRO15;

import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;

public class insert extends Activity  {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 SQLiteDatabase db;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        db=openOrCreateDatabase("database1",SQLiteDatabase.CREATE_IF_NECESSARY, null);
  db.execSQL("create table if not exists stud(id integer primary key,name text,age integer)");
    }
}
update.java
package vc.PRO15;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class update extends Activity implements OnClickListener, TextWatcher, OnItemClickListener  {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 SQLiteDatabase db;
 EditText txtname,txtage,txtid;
 Button btnedit,btncancel;
 TextView lblage;
 ListView lv;
 String name[];
 int flag=-1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.update);
        db=openOrCreateDatabase("database1",SQLiteDatabase.CREATE_IF_NECESSARY, null);
  db.execSQL("create table if not exists stud(id integer primary key AUTOINCREMENT,name text,age integer)");
  
  lblage=(TextView) findViewById(R.id.textView2);
  txtname=(EditText) findViewById(R.id.txtname);
  txtage=(EditText) findViewById(R.id.txtage);
  txtid=(EditText) findViewById(R.id.txtid);
  btnedit=(Button) findViewById(R.id.btnedit);
  btncancel=(Button) findViewById(R.id.btncancel);
  
  lv=(ListView) findViewById(R.id.list);
  lv.setVisibility(-1);
  txtid.setVisibility(-1);
  Intent myintent=getIntent();
  flag=myintent.getIntExtra("flag", 0);
  if(flag==0)
  {
   try
   {
    String label=myintent.getStringExtra("label");
    Cursor cur=db.query("stud",null,"name=?",new String []{label},null, null,null);
    cur.moveToFirst();
    Toast.makeText(this,cur.getString(0)+"", 1).show();
    txtid.setText(cur.getString(0)+"");
    txtname.setText(cur.getString(1));
    txtage.setText(cur.getString(2));
    btnedit.setText("Update");
    txtage.setEnabled(true);
   }
   catch(Exception e)
   {
    Toast.makeText(this,e.toString(), 1).show();
   }
  }
  else if(flag==1)
  {
   txtname.addTextChangedListener(this);
   lv.setVisibility(0);
   invisible();
   txtage.setEnabled(false);
  }
  else if(flag==2)
  {
   txtname.addTextChangedListener(this);
   lv.setVisibility(0);
   invisible();
   btnedit.setText("Delete");
  }
  else if(flag==5)
  {
   btnedit.setText("Save");
  }
  btnedit.setOnClickListener(this);
  btncancel.setOnClickListener(this);
  lv.setOnItemClickListener(this);
    }
    public void invisible()
    {
     lblage.setVisibility(-1);
     txtage.setVisibility(-1);
     btncancel.setVisibility(-1);
     btnedit.setVisibility(-1);
    }
    public void visible()
    {
     lblage.setVisibility(0);
     txtage.setVisibility(0);
     btncancel.setVisibility(0);
     btnedit.setVisibility(0);
    }
    public void clear()
    {
     txtid.setText("");
     txtname.setText("");
     txtage.setText("");
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  Button action=(Button) v;
  if(action.getText().toString().equals("Edit"))
  {
   txtage.setEnabled(true);
   btnedit.setText("Update");
  }
  else if(action.getText().toString().equals("Update"))
  {
   ContentValues value=new ContentValues();
   value.put("name", txtname.getText().toString());
   value.put("age",txtage.getText().toString());
   db.update("stud",value, "id=?", new String[]{txtid.getText().toString()});
   btnedit.setText("Edit");
   Toast.makeText(this,"Update Successfully",1000).show();
   startActivity(new Intent(this,PRO15Activity.class));
  }
  else if(action.getText().toString().equals("Delete"))
  {
   db.delete("stud", "id=?",new String[]{txtid.getText().toString()});
   Toast.makeText(this, "Record Deleted...", Toast.LENGTH_LONG).show();
   startActivity(new Intent(this,PRO15Activity.class));
  }
  else if(action.getText().toString().equals("Save"))
  {
   if(txtname.getText().toString().equals(""))
   {
    Toast.makeText(this,"Please Enter Name ...", 1).show();
   }
   else if(txtage.getText().toString().equals(""))
   {
    Toast.makeText(this,"Please Enter Age ...", 1).show();
   }
   else
   {
    try
    {
     Cursor cur=db.query("stud", null, "name=?",new String[]{txtname.getText().toString()},null, null,null);
     if(cur.getCount()>0)
     {
      Toast.makeText(this,"Name Allready Exists ...",1).show();
     }
     else
     {
       ContentValues values=new ContentValues();
       values.put("name", txtname.getText().toString());
       values.put("age",txtage.getText().toString());
       db.insert("stud",null, values);
       Toast.makeText(this,"Record Saved...", 1).show();
     }
    }
    catch(Exception e)
    {
     Toast.makeText(this,e.toString(), 1).show();
    }
   }
  }
  else if(v.getId()==btncancel.getId())
  {
   startActivity(new Intent(this,PRO15Activity.class));
  }
 }
 public void enabled()
 {
  txtage.setEnabled(true);
 }
 public void disabled()
 {
  txtage.setEnabled(false);
 }
 @Override
 public void afterTextChanged(Editable arg0) {
  // TODO Auto-generated method stub
  Cursor cur=db.rawQuery("select *from stud where name like '"+txtname.getText().toString()+"%'",null);
  int len=cur.getCount();
  try
  {
   if(txtname.getText().toString().equals(""))
   {
    lv.setAdapter(null);
    name[0]="";
   }
   else if(len>0)
   {
    if(txtname.getText().toString().equals(""))
    {
     lv.setAdapter(null);
     for(int i=0; i<len; i++)
      name[i]="";
    }
    else if(len>0)
    {
     name=new String[len];
     cur.moveToNext();
     for(int i=0; i<len; i++)
     {
      name[i]=cur.getString(1);
      cur.moveToNext();
     }
    }
    ArrayAdapter<String> aa=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,name);
    lv.setAdapter(aa);
   }
   else
   {
    Toast.makeText(this,"Recoerd Not Found...", 1000).show();
   }
  }
  catch(Exception e)
  {
   Toast.makeText(this,e.toString(),1000).show();
  }
 }
 @Override
 public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
   int arg3) {
  // TODO Auto-generated method stub
 }
 @Override
 public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
  // TODO Auto-generated method stub
 }
 @Override
 public void onItemClick(AdapterView<?> p, View v, int pos, long c) {
  // TODO Auto-generated method stub
  TextView iname=(TextView) v;
  String sname=iname.getText().toString();
  
  Cursor cur=db.rawQuery("select *from stud",null);
  if(cur.getCount()>0)
  {
   while(cur.moveToNext())
   {
    if(sname.equals(cur.getString(1)))
    {
     txtid.setText(cur.getInt(0)+"");
     txtname.setText(cur.getString(1));
     txtage.setText(cur.getString(2));
     break;
    }
   }
   visible();
   lv.setVisibility(-1);
  }
 }
}

Create an application to call specific entered number by user in the EditText

Pro14Activity.java
package ps.pro14;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Pro14Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 EditText num;
 Button dial;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        num=(EditText) findViewById(R.id.editTextnum);
        dial=(Button) findViewById(R.id.buttondial);
        
        dial.setOnClickListener(this);
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(v.getId()==dial.getId())
  {
   Intent myintent=new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+num.getText()));
   startActivity(myintent);
  }
 }
}

Read messages from the mobile and display it on the screen.

Pro13Activity.java
package ps.pro13;

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class Pro13Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 TextView txtmsg;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        txtmsg=(TextView) findViewById(R.id.TextViewmsgs);
        
        Uri u=Uri.parse("content://sms/inbox");
        Cursor cur=managedQuery(u, null, null, null, null);
        
        String msg="";
        while(cur.moveToNext())
        {
         msg+=cur.getString(2)+":\n\t"+cur.getString(11)+"\n\n";
        }
        txtmsg.setText(msg);
       
    }
}

Understanding content providers and permissions:
a. Read phonebook contacts using content providers and display in list.

Pro12Activity.java
Note:Give "READ_CONTACTS" permission in android Manifest file.
package ps.pro12;

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Pro12Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 ListView mylist;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mylist=(ListView) findViewById(R.id.listView1);
        
        //Uri u=Uri.parse("content://contacts/people");
        Uri u=Phones.CONTENT_URI;
        Cursor cur=managedQuery(u, null,null,null,null);
        
        String names[]=new String[cur.getCount()];
        
        int i=0;
        while(cur.moveToNext())
        {
         names[i++]=cur.getString(15)+"ntttt"+cur.getString(7);
        }
        
        ArrayAdapter<String> aa=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,names);
        mylist.setAdapter(aa);
    }
}

Understanding of UI :
a. Create an UI such that , one screen have list of all the types of cars.
b. On selecting of any car name, next screen should show Car details like : name , launched date , company name, images(using gallery) if available, show different colors in which it is available.

Pro11Activity.java
package ps.pro11;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class Pro11Activity extends Activity implements OnItemClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 ListView lv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        lv=(ListView) findViewById(R.id.listView1);
        lv.setOnItemClickListener(this);
    }
 @Override
 public void onItemClick(AdapterView arg0, View arg1, int pos, long arg3) {
  // TODO Auto-generated method stub
  Toast.makeText(this, pos + " click", Toast.LENGTH_SHORT).show();
  
  Intent myintent=new Intent(this,Details.class);
  myintent.putExtra("id", pos);
  startActivity(myintent);
 }
}
ImageAdapter.java
package ps.pro11;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Context c;
 int id;
 
 Integer listmarutisuzuki[]={R.drawable.marutisuzuki1,R.drawable.marutisuzuki2,R.drawable.marutisuzuki3};
 Integer listalto[]={R.drawable.alto1,R.drawable.alto2,R.drawable.alto3};
 Integer listhundai[]={R.drawable.hundai1,R.drawable.hundai2,R.drawable.hundai3};
 Integer listoodi[]={R.drawable.oodi1,R.drawable.oodi2,R.drawable.oodi3};
 
 public ImageAdapter(Context c,int id)
 {
  this.c=c;
  this.id=id;
  Log.d("master", id+"clicked");
 }
 @Override
 public int getCount() {
  // TODO Auto-generated method stub
  
  if(id==0)
  {
   return listmarutisuzuki.length; 
  }
  if(id==1)
  {
   return listalto.length;
  }
  if(id==2)
  {
   return listhundai.length;
  }
  if(id==3)
  {
   return listoodi.length;
  }
  return listmarutisuzuki.length;
 }

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

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

 @Override
 public View getView(int arg0, View arg1, ViewGroup arg2) {
  // TODO Auto-generated method stub
  ImageView img=new ImageView(c);
  
  if(id==0)
  {
   img.setImageResource(listmarutisuzuki[arg0]);
   
  }
  if(id==1)
  {
   img.setImageResource(listalto[arg0]);
  }
  if(id==2)
  {
   img.setImageResource(listhundai[arg0]);
  }
  if(id==3)
  {
   img.setImageResource(listoodi[arg0]);
     
  }
  img.setScaleType(ImageView.ScaleType.FIT_XY);
  img.setLayoutParams(new Gallery.LayoutParams(120, 200));
  return img;
 }
}
Details.java
package ps.pro11;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Gallery;
import android.widget.TextView;
import android.widget.Toast;

public class Details extends Activity implements OnItemClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 TextView tvname,tvdate,tvcompanyname;
 Gallery gv;
 ImageAdapter obj;
 int id=0;
 
 Integer listmarutisuzuki[]={R.drawable.marutisuzuki1,R.drawable.marutisuzuki2,R.drawable.marutisuzuki3};
 Integer listalto[]={R.drawable.alto1,R.drawable.alto2,R.drawable.alto3};
 Integer listhundai[]={R.drawable.hundai1,R.drawable.hundai2,R.drawable.hundai3};
 Integer listoodi[]={R.drawable.oodi1,R.drawable.oodi2,R.drawable.oodi3};
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.details);
 
  tvname=(TextView) findViewById(R.id.textViewname);
  tvdate=(TextView) findViewById(R.id.textViewdate);
  tvcompanyname=(TextView) findViewById(R.id.textViewcompanyname);
  
  gv=(Gallery) findViewById(R.id.gallery1);
  
  Intent myintent=getIntent();
  id=myintent.getIntExtra("id", 0);
  
  if(id==0)
  {
   tvname.setText("maruti suzuki");
   tvdate.setText("1-12-1987");
   tvcompanyname.setText("Maruti");
  }
  if(id==1)
  {
   Toast.makeText(this, id+" clicked", Toast.LENGTH_SHORT).show();
   tvname.setText("maruti alto");
   tvdate.setText("2-01-1988");
   tvcompanyname.setText("Maruti");
  }
  if(id==2)
  {
   tvname.setText("hundai i10");
   tvdate.setText("2-12-1987");
   tvcompanyname.setText("Hundai");
  }
  if(id==3)
  {
   tvname.setText("oodi");
   tvdate.setText("1-10-1993");
   tvcompanyname.setText("Oodi");
  }

  obj=new ImageAdapter(this,id);
  gv.setAdapter(obj);
  gv.setOnItemClickListener(this);
 }
 @Override
 public void onItemClick(AdapterView arg0, View arg1, int pos, long arg3) 
 {
  // TODO Auto-generated method stub
  Intent myintent2=new Intent(this,enlarge.class);
  if(id==0)
   myintent2.putExtra("id", listmarutisuzuki[pos]);
  else if(id==1)
   myintent2.putExtra("id", listalto[pos]);
  else if(id==2)
   myintent2.putExtra("id", listhundai[pos]);
  else if(id==3)
   myintent2.putExtra("id", listoodi[pos]);
  
   
  //myintent2.putExtra("id", arg0.getId());
  startActivity(myintent2);
  //Toast.makeText(this," selected", Toast.LENGTH_SHORT).show();
 }
}
enlarge.java
package ps.pro11;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;

public class enlarge extends Activity 
{
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 ImageView imgview;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.enlarge);
  
  Intent myintent2=getIntent();
  int id=myintent2.getIntExtra("id", 0);
  imgview=(ImageView) findViewById(R.id.imageView1);
  imgview.setImageResource(id);
 }
}

Create an application that will have spinner with list of animation names. On selecting animation name , that animation should affect on the images displayed below.

Pro10Activity.java
package ps.pro10;

import android.app.Activity; 
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
import android.widget.Spinner;

public class Pro10Activity extends Activity implements OnItemSelectedListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Spinner spin;
 ImageView imgmaster;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        spin=(Spinner) findViewById(R.id.spinnereffect);
        imgmaster=(ImageView) findViewById(R.id.imageViewmaster);
        
        spin.setOnItemSelectedListener(this); 
    }

 @Override
 public void onItemSelected(AdapterView arg0, View arg1, int arg2,
   long arg3) {
  // TODO Auto-generated method stub
  Animation anim=AnimationUtils.loadAnimation(this, R.anim.alpha);
  if(spin.getSelectedItem().equals("alpha"))
   anim=AnimationUtils.loadAnimation(this, R.anim.alpha);
  else if(spin.getSelectedItem().equals("Rotate"))
   anim=AnimationUtils.loadAnimation(this, R.anim.rotate);
  else if(spin.getSelectedItem().equals("Scale"))
   anim=AnimationUtils.loadAnimation(this, R.anim.scale);
  else if(spin.getSelectedItem().equals("Translate"))
   anim=AnimationUtils.loadAnimation(this, R.anim.translate);
  
  imgmaster.startAnimation(anim);
 }

 @Override
 public void onNothingSelected(AdapterView arg0) {
  // TODO Auto-generated method stub
  
 }
}

Create an application that will display toast(Message) on specific interval of time.

Pro8Activity.java
package ps.pro8;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.Chronometer.OnChronometerTickListener;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Pro8Activity extends Activity implements OnClickListener, OnChronometerTickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 EditText editsec;
 Button btclick;
 TextView msg;
 Chronometer timer;
 int sec=0,delay=0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        editsec=(EditText) findViewById(R.id.editTextsec);
        btclick=(Button) findViewById(R.id.buttonclick);
        msg=(TextView) findViewById(R.id.textViewmsg);
        timer=(Chronometer) findViewById(R.id.chronometer1);
        
        timer.setVisibility(-1);
        
        btclick.setOnClickListener(this);
        timer.setOnChronometerTickListener(this);
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(v.getId()==btclick.getId())
  {
   delay=Integer.parseInt(editsec.getText().toString());
   sec=0;
   timer.start();
  }
 }
 @Override
 public void onChronometerTick(Chronometer arg0) {
  // TODO Auto-generated method stub
  
  msg.setText("Text Next Message is [ 0"+ (delay-sec) +" ] sec delay");
  sec++;
  if(sec==delay)
  {
   sec=0;
   Toast.makeText(this, "Heres The Message...", Toast.LENGTH_SHORT).show();
  }
 }
}

Understand Menu option.
a. Create an application that will change color of the screen, based on selected options from the menu.

Pro7Activity.java
package ps.pro7;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AbsoluteLayout;

@SuppressWarnings("deprecation")
public class Pro7Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 
 AbsoluteLayout al;
    
 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        al=(AbsoluteLayout) findViewById(R.id.alayout);
        al.setOnCreateContextMenuListener(this);
    }
 public void createMenu(Menu menu)
 {
  
  MenuItem m1=menu.add(0,0,0,"RED");
  m1.setAlphabeticShortcut('r');
  m1.setIcon(R.drawable.icon);
  
  MenuItem m2=menu.add(0,1,1,"GREEN");
  m2.setAlphabeticShortcut('g');
  m1.setIcon(R.drawable.icon);
  
  MenuItem m3=menu.add(0,2,2,"BLUE");
  m3.setAlphabeticShortcut('b');
  m1.setIcon(R.drawable.icon);
     
 }
 public void listenMenu(MenuItem item)
 {
  int id=item.getItemId();
     switch(id)
     {
     case 0:
      al.setBackgroundColor(Color.RED);
      break;
     case 1:
      al.setBackgroundColor(Color.GREEN);
      break;
     case 2:
      al.setBackgroundColor(Color.BLUE);
      break;
     }
 }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
     // TODO Auto-generated method stub
     super.onCreateOptionsMenu(menu);
     createMenu(menu);
     return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
     // TODO Auto-generated method stub
     super.onOptionsItemSelected(item);
     listenMenu(item);
     return true;
    }
    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
      ContextMenuInfo menuInfo) {
     // TODO Auto-generated method stub
     super.onCreateContextMenu(menu, v, menuInfo);
     createMenu(menu);
    }
    @Override
    public boolean onContextItemSelected(MenuItem item) {
     // TODO Auto-generated method stub
     super.onContextItemSelected(item);
     listenMenu(item);
     return true;
    }
}

Understand resource folders :
a. Create spinner with strings taken from resource folder(res >> value folder).
b. On changing spinner value, change image.

Pro6Activity.java
package ps.pro6;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
import android.widget.Spinner;

public class Pro6Activity extends Activity implements OnItemSelectedListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Spinner spin;
 ImageView img;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        spin=(Spinner) findViewById(R.id.spinnernames);
        img=(ImageView) findViewById(R.id.imageView1);

        spin.setOnItemSelectedListener(this);
    }

 @Override
 public void onItemSelected(AdapterView arg0, View arg1, int arg2,
   long arg3) {
  // TODO Auto-generated method stub
  String name=spin.getSelectedItem().toString();
  if(name.equals("AMI"))
   img.setImageResource(R.drawable.ami);
  else if(name.equals("MEHUL"))
   img.setImageResource(R.drawable.mehul);
  else if(name.equals("PANKAJ"))
   img.setImageResource(R.drawable.pankaj);
  else if(name.equals("JIGNESH"))
   img.setImageResource(R.drawable.jignesh);
  else if(name.equals("VIJAY"))
   img.setImageResource(R.drawable.vijay);
  else if(name.equals("SATISH"))   
   img.setImageResource(R.drawable.satish);

 }
 @Override
 public void onNothingSelected(AdapterView arg0) {
  // TODO Auto-generated method stub
  
 }
}

Create an application that will pass some number to the next screen , and on the next screen that number of items should be display in the list.

Pro5Activity
package ps.pro5;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Pro5Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 EditText editnum;
 Button btshow;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        editnum=(EditText) findViewById(R.id.editTextNumber);
        btshow=(Button) findViewById(R.id.buttonshow);
        
        btshow.setOnClickListener(this);
    
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(v.getId()==btshow.getId())
  {
   Intent myintent=new Intent(this,listActivity.class);
   myintent.putExtra("num", Integer.parseInt(editnum.getText().toString()));
   this.startActivity(myintent);
  }
 }
}
listActivity.java
package ps.pro5;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class listActivity extends Activity implements  OnItemClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 ListView lv;
 String items[];
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listlayout);
        
        lv=(ListView) findViewById(R.id.listViewItems);
        int num=getIntent().getIntExtra("num", 0);
        items=new String[num];
        for(int i=0;i<num;i++)
        {
         items[i]="item "+(i+1);
        }
        ArrayAdapter<String> arr=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,items);
        lv.setAdapter(arr);
       
        lv.setOnItemClickListener(this);
    }
 @Override
 public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
  // TODO Auto-generated method stub
  Toast.makeText(this,items[pos] + " selected", Toast.LENGTH_SHORT).show();
 }
}

Create and Login application as above . On successful login , open browser with any URL.

Pro4Activity.java
package ps.pro4;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Pro4Activity extends Activity implements OnClickListener {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Button btlogin,btclear;
 EditText editemail,editpass;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        editemail=(EditText) findViewById(R.id.editemail);
        editpass=(EditText) findViewById(R.id.editpass);
        btlogin=(Button) findViewById(R.id.btlogin);
        btclear=(Button) findViewById(R.id.btclear);
        btlogin.setOnClickListener(this);
        btclear.setOnClickListener(this);
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  Button action=(Button) v;
  if(action.getId()==btlogin.getId())
  {
   String email=editemail.getText().toString();
   String pass=editpass.getText().toString();
   
   if(email.equals("pankaj@gmail.com") && pass.equals("pankaj"))
   {
    Intent myintent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.gmail.com"));
    this.startActivity(myintent);
   }
   else
   {
    Toast.makeText(this,"Sorry", Toast.LENGTH_SHORT).show();
   }
   
  }
  else if(action.getId()==btclear.getId())
  {
   if(!editemail.getText().toString().equals("") ||  !editpass.getText().toString().equals(""))
   {
    editemail.setText("");
    editpass.setText("");
   }
   else
   {
    Toast.makeText(this,"Already Cleared...", Toast.LENGTH_SHORT).show();
   }
  }
 }
}

Create login application where you will have to validate EmailID(UserName). Till the username and password is not validated , login button should remain disabled.

PRO3Activity.java
package vc.pro3;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class PRO3Activity extends Activity implements OnClickListener, TextWatcher {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 Button btnLogin,btnCancel;
 EditText txtuname,txtpass;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btnLogin=(Button) findViewById(R.id.btnLogin);
        btnCancel=(Button) findViewById(R.id.btnCancel);
        txtuname=(EditText) findViewById(R.id.txtuname);
        txtpass=(EditText)findViewById(R.id.txtpass);
        
        btnLogin.setOnClickListener(this);
        btnCancel.setOnClickListener(this);
        btnLogin.setEnabled(false);
        txtuname.addTextChangedListener(this);
        txtpass.addTextChangedListener(this);
    }
    
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(v.getId()==btnLogin.getId())
  {
   if(txtuname.getText().toString().equals(""))
   {
    Toast.makeText(this,"Please Enter Use Name", Toast.LENGTH_SHORT).show();
   }
   else if(txtpass.getText().toString().equals(""))
   {
    Toast.makeText(this,"Please Enter Pass", Toast.LENGTH_SHORT).show();
   }
   else 
   {
     Toast.makeText(this,"Login Success Fully", Toast.LENGTH_SHORT).show();
   }
   
  }
  else if(v.getId() == btnCancel.getId())
  {
   if(txtuname.getText().toString().equals("") && txtpass.getText().toString().equals(""))
   {
    Toast.makeText(this,"Text is Already Empty...",Toast.LENGTH_SHORT).show();
   }
   else
   {
    
    txtuname.setText("");
    txtpass.setText("");
   }
  }
 }
 @Override
 public void afterTextChanged(Editable v) {
  // TODO Auto-generated method stub
  int firstat_rat,lastat_rat,first_dot,last_dot;
  boolean flag_email=true,flag_pass=true,flag=false;
  String email,pass;
   email=txtuname.getText().toString();
   pass=txtpass.getText().toString();
       
  firstat_rat=email.indexOf("@");
  lastat_rat=email.lastIndexOf("@");
  first_dot=email.indexOf(".");
  last_dot=email.lastIndexOf(".");
     
  if(firstat_rat<=0)
  {
   flag_email=false;
  }
  else if(firstat_rat!=lastat_rat )
  {
   flag_email=false;
  }
  else if(lastat_rat==email.length()-1)
  {
   flag_email=false;
  }
  else if(first_dot<= 0)
  {
   flag_email=false;
  }
  else if('.'==email.charAt(lastat_rat-1) ||'.'==email.charAt(lastat_rat+1))
  {
   flag_email=false;
  }
  else if(last_dot==email.length()-1)
  {
   flag_email=false;
  }
  else if(last_dot<lastat_rat)
  {
   flag_email=false;
  }
  else if(first_dot!=last_dot)
  {
   for(int i=first_dot; i<=last_dot; i++)
   {
    if(email.charAt(i)=='.')
    {
     if(flag==true)
     {
      flag_email=false;
      break;
     }
     else
      flag=true;
    }
    else
    {
     flag=false;
    }
   }
  }
  else
  {
   flag_email=true;
  }
  
  if(pass.equals(""))
  {
   flag_pass=false;
  }
  else
  {
   flag_pass=true;
  }
  if(flag_email==true && flag_pass==true )
    btnLogin.setEnabled(true);
  else 
   btnLogin.setEnabled(false);
 }

 @Override
 public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
   int arg3) {
  // TODO Auto-generated method stub
  
 }

 @Override
 public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
  // TODO Auto-generated method stub
  
 }
}