how to capture picture and preview the same in android?
<pre><code> public class CameraActivity extends Activity {

Button camera;
ImageView imv;
final static int CAMERA_RESULT = 0;
Intent i;

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

    camera = (Button) findViewById(R.id.button1);
    imv = (ImageView) findViewById(R.id.imageView1);
    camera.setOnClickListener( new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            i = new Intent(
            "android.provider.MediaStore.ACTION_IMAGE_CAPTURE");
    startActivityForResult(i, CAMERA_RESULT);
        }
    });
    }
     protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == RESULT_OK) {
        Bundle extras = intent.getExtras();
        Bitmap bmp = (Bitmap) extras.get("data");
        imv = (ImageView) findViewById(R.id.imageView1);
        imv.setImageBitmap(bmp);
    }
    }
    }
</code></pre>

<p>main.xml</p>

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

&lt;ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    /&gt;

&lt;Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>manifest.xml</p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="camera.mohit"
 android:versionCode="1"
 android:versionName="1.0" &gt;
 &lt;uses-sdk android:minSdkVersion="8" /&gt;
 &lt;uses-feature android:name="android.hardware.camera"&gt;&lt;/uses-feature&gt;
 &lt;uses-permission android:name="android.permission.CAMERA"/&gt;
 &lt;application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" &gt;
    &lt;activity
        android:name=".CameraActivity"
        android:label="@string/app_name" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
&lt;/application&gt;
</code></pre>

<p>
Logcat:</p>

<pre><code>03-06 22:39:36.772: D/AndroidRuntime(282): Shutting down VM
03-06 22:39:36.772: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-06 22:39:36.842: E/AndroidRuntime(282): FATAL EXCEPTION: main
03-06 22:39:36.842: E/AndroidRuntime(282): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.provider.MediaStore.ACTION_IMAGE_CAPTURE }
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.app.Activity.startActivityForResult(Activity.java:2817)
03-06 22:39:36.842: E/AndroidRuntime(282):  at camera.mohit.CameraActivity$1.onClick(CameraActivity.java:33)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.view.View.performClick(View.java:2408)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.view.View$PerformClick.run(View.java:8816)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.os.Handler.handleCallback(Handler.java:587)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.os.Handler.dispatchMessage(Handler.java:92)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.os.Looper.loop(Looper.java:123)
03-06 22:39:36.842: E/AndroidRuntime(282):  at android.app.ActivityThread.main(ActivityThread.java:4627)
03-06 22:39:36.842: E/AndroidRuntime(282):  at java.lang.reflect.Method.invokeNative(Native Method)
03-06 22:39:36.842: E/AndroidRuntime(282):  at java.lang.reflect.Method.invoke(Method.java:521)
03-06 22:39:36.842: E/AndroidRuntime(282):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-06 22:39:36.842: E/AndroidRuntime(282):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-06 22:39:36.842: E/AndroidRuntime(282):  at dalvik.system.NativeStart.main(Native Method)
03-06 22:39:42.611: I/Process(282): Sending signal. PID: 282 SIG: 9
03-06 22:39:59.422: D/AndroidRuntime(290): Shutting down VM
03-06 22:39:59.422: W/dalvikvm(290): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-06 22:39:59.442: E/AndroidRuntime(290): FATAL EXCEPTION: main
03-06 22:39:59.442: E/AndroidRuntime(290): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.provider.MediaStore.ACTION_IMAGE_CAPTURE }
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.app.Activity.startActivityForResult(Activity.java:2817)
03-06 22:39:59.442: E/AndroidRuntime(290):  at camera.mohit.CameraActivity$1.onClick(CameraActivity.java:33)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.view.View.performClick(View.java:2408)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.view.View$PerformClick.run(View.java:8816)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.os.Handler.handleCallback(Handler.java:587)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.os.Handler.dispatchMessage(Handler.java:92)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.os.Looper.loop(Looper.java:123)
03-06 22:39:59.442: E/AndroidRuntime(290):  at android.app.ActivityThread.main(ActivityThread.java:4627)
03-06 22:39:59.442: E/AndroidRuntime(290):  at java.lang.reflect.Method.invokeNative(Native Method)
03-06 22:39:59.442: E/AndroidRuntime(290):  at java.lang.reflect.Method.invoke(Method.java:521)
03-06 22:39:59.442: E/AndroidRuntime(290):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-06 22:39:59.442: E/AndroidRuntime(290):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-06 22:39:59.442: E/AndroidRuntime(290):  at dalvik.system.NativeStart.main(Native Method)
03-06 22:40:03.022: I/Process(290): Sending signal. PID: 290 SIG: 9
</code></pre>

<p>Above is my 3 files i'm using to get the pic preview from camera. I have gone through this thread : <a href="http://stackoverflow.com/questions/5991319/capture-image-from-camera-and-display-in-activity">Capture Image from Camera and Display in Activity</a>. Don't know why but things are getting worst.</p>
