Auto search on listview TextWatcher android

activity class:

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
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.Toast;

public class Search_DemoMainActivity extends Activity {



private ListView lv1;
   private String lv_arr[] =
    {
"Android", "iPhone",
"BlackBerry", "me",
"J2ME", "Listview",
"ArrayAdapter", "ListItem",
"Us", "UK", "India"
   };
ListView lst;
EditText edt;
ArrayAdapter<String> arrad;
Button btn;




    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     
        lv1=(ListView)findViewById(R.id.listView1);
        edt = (EditText) findViewById(R.id.editText1);
     
             
     
        btn=(Button)findViewById(R.id.button1);
     
        arrad =  new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr);
     
        lv1.setAdapter(arrad);
        // By using setTextFilterEnabled method in listview we can filter the listview items.
 
        btn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

// TODO Auto-generated method stub

}
});
     
     
        lv1.setTextFilterEnabled(true);
     
        lv1.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {

// TODO Auto-generated method stub

AlertDialog.Builder builder = new AlertDialog.Builder(Search_DemoMainActivity.this);

builder.setTitle("Pick a color");

builder.setSingleChoiceItems(lv_arr, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {

Toast.makeText(getApplicationContext(), lv_arr[item], Toast.LENGTH_SHORT).show();

}});

AlertDialog alert = builder.create();
alert.show();
}
});
     
     
        edt.addTextChangedListener(new TextWatcher()    
        {  
       
    public void onTextChanged( CharSequence arg0, int arg1, int arg2, int arg3)  
       {          
    // TODO Auto-generated method stub  
   
       }  
   
   
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
        {      
        // TODO Auto-generated method stub  
       
        }  
       
        @Override    
        public void afterTextChanged( Editable arg0)  
                   {
               
        Search_DemoMainActivity.this.arrad.getFilter().filter(arg0);
       
                   }  
       
        });
        }
       
 
     
    }
==============================================================
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" >

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

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <requestFocus />
    </EditText>

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

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

</LinearLayout>


How can make AudioRecorder android

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    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="125dp"
        android:layout_height="wrap_content"
        android:text="Play" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_below="@+id/button1"
        android:layout_marginTop="20dp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <MediaController
            android:id="@+id/mediaController1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
         
             >
        </MediaController>

    </LinearLayout>


    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="44dp"
        android:layout_toRightOf="@+id/button1"
        android:text="Stop" />

</RelativeLayout>

=============================================
activity class :AudioRecoderActivity .java
===================================

code :
====================

import java.io.File;
import java.io.IOException;
import android.app.Activity;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.SurfaceView;
import android.view.View.OnClickListener;
import android.widget.Button;


public class AudioRecoderActivity extends Activity {
private SurfaceHolder surfaceHolder;
private SurfaceView surfaceView;
public MediaRecorder mrec = new MediaRecorder();
private Button startRecording ;
private Button stopRecording ;
//private Button stopRecording = null;
File video;
AudioRecorder audioRecorder;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
 
    startRecording = (Button)findViewById(R.id.button1);
    stopRecording= (Button)findViewById(R.id.button2);
 
 
  /*recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
44100, AudioFormat.CHANNEL_IN_STEREO,
AudioFormat.ENCODING_PCM_16BIT, 1000);
*/
 
    audioRecorder=new AudioRecorder();
 
 
    startRecording.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

try {
audioRecorder.start();
} catch (IOException e) {


}


}
});
 
    stopRecording.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

try {
audioRecorder.stop();
} catch (IOException e) {


}


}
});
 
}
}

===============================================
2 nd java class :AudioRecorder
=========================




import java.io.IOException;
import java.util.Random;

import android.media.MediaRecorder;

public class AudioRecorder {

final MediaRecorder recorder = new MediaRecorder();
 public void start() throws IOException {

   recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
   recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
   recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

   int min = 1;
   int max = 999;
 
    Random r = new Random();
    int ramNum = r.nextInt(max - min + 1) + min;

    recorder.setOutputFile("/mnt/sdcard/recode_"+ramNum+".3gp");
    recorder.prepare();
    recorder.start();
 
 }


 public void stop() throws IOException {
   recorder.stop();
   recorder.release();
 }


}
===================================================================
take two permission in menifest :

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>






how can take picture by camera simple code android

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="Capture Image" />

    <Button
        android:id="@+id/btCamera_main"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Take Picture" />

</LinearLayout>

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

activity class Name=CameraTestAppsActivity.java
============
code :
======

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class CameraTestAppsActivity extends Activity {

Button btCamera;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btCamera=(Button)findViewById(R.id.btCamera_main);
     
     
        btCamera.setOnClickListener(new OnClickListener()
        {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(mInterface.getTempFile()));
     startActivityForResult(intent, 0);

}
});
     
   
    }
 
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK && requestCode == 0) {
    String result = data.toURI();
    // ...
    }
    }
}

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


how can dwonlode pdf,music file,vedio from url or http server programing android


call this function :

 private void startDownload() {
     //   String url = Searchpdf.ArrUrl.get(IntPos);// set your url where from dwonlode the file li
        new DownloadFileAsync().execute("http://db.lcs.mit.edu/madden/html/vldb04.pdf");
    }

and after ..

 @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case DIALOG_DOWNLOAD_PROGRESS:
                mProgressDialog = new ProgressDialog(this);
                mProgressDialog.setMessage("Downloading file..");
                mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                mProgressDialog.setCancelable(false);
                mProgressDialog.show();
                return mProgressDialog;
            default:
                return null;
        }
    }
    class DownloadFileAsync extends AsyncTask<String, String, String> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            showDialog(DIALOG_DOWNLOAD_PROGRESS);
           
            //new added
            ProgressBar myProgress = (ProgressBar)findViewById(R.id.progressBar);
          //  myProgress.setMax(maxValue);
            myProgress.setVisibility(View.GONE);
        }

        @Override
        protected String doInBackground(String... aurl) {
            int count;

            try {
                URL url = new URL(aurl[0]);
                URLConnection conexion = url.openConnection();
                conexion.connect();
               // File root = Environment.getExternalStorageDirectory();
                int lenghtOfFile = conexion.getContentLength();
                Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);
               
                InputStream input = new BufferedInputStream(url.openStream());
                //  "/sdcard/moon.m4v"
               
                OutputStream output = new FileOutputStream("/sdcard/"+fileName);
               // FileOutputStream f = new FileOutputStream(new File(root, fileName));

                byte data[] = new byte[1024];

                long total = 0;

                while ((count = input.read(data)) != -1) {
                    total += count;
                    publishProgress(""+(int)((total*100)/lenghtOfFile));
                    output.write(data, 0, count);
                }

                output.flush();
                output.close();
                input.close();
            } catch (Exception e) {}
            return null;

        }
        protected void onProgressUpdate(String... progress) {
             Log.d("ANDRO_ASYNC",progress[0]);
             mProgressDialog.setProgress(Integer.parseInt(progress[0]));
             //newly added
          //   myProgress.setProgress(Integer.parseInt(progress[0]));
        }

        @Override
        protected void onPostExecute(String unused) {
            dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
        }
    }


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