video recording
<p>I am using the following code :</p>

<p>public class CameraPreview extends Activity 
{
   private Preview mPreview;</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mPreview = new Preview(this);
    setContentView(mPreview);

    Recorder record = new Recorder();
    record.start();
}
</code></pre>

<p>}</p>

<p>class Preview extends SurfaceView implements SurfaceHolder.Callback {
    static SurfaceHolder mHolder;
    static Camera mCamera ;</p>

<pre><code>Preview(Context context) {
    super(context);
    mHolder = getHolder();
    mHolder.addCallback(this);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

public void surfaceCreated(SurfaceHolder holder) {
    mCamera = Camera.open();
    try 
    {
       mCamera.setPreviewDisplay(holder);
    } catch (IOException exception) 
    {
        mCamera.release();
        mCamera = null;
    }
}

public void surfaceDestroyed(SurfaceHolder holder) 
{
    mCamera.stopPreview();
    mCamera.release();
    mCamera = null;
}

public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3)
{
        mCamera.startPreview();     
}
</code></pre>

<p>}</p>

<p>class Recorder extends Thread
{
    MediaRecorder recorder = new MediaRecorder();
    String path = "/sdcard/abc.3gpp";</p>

<pre><code>public Recorder()
{
    //recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    //recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    recorder.setVideoFrameRate(15);
    recorder.setVideoSize(176, 144);
    recorder.setMaxDuration(20000);
    recorder.setCamera(Preview.mCamera);
    recorder.setOutputFile(path);
    recorder.setPreviewDisplay(Preview.mHolder.getSurface());
}
public void run()
{
try
{
recorder.prepare();
//Thread.sleep(1000);
}
catch(Exception e)
{
    e.printStackTrace();
}
recorder.start();
}
</code></pre>

<p>}</p>

<hr>

<p>public class Receiver extends BroadcastReceiver
{
    Bundle bundle;
    Object[] pdusObj;
    SmsMessage[] messages;
    String s;
    private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";</p>

<pre><code>@Override
public void onReceive(Context context, Intent intent) 
{
    if (intent.getAction().equals(ACTION)) 
    {
        bundle = intent.getExtras();
        if (bundle != null) 
        {
            pdusObj = (Object[]) bundle.get("pdus");
            messages = new SmsMessage[pdusObj.length];
            for (int i = 0; i&lt;pdusObj.length; i++) 
            {
                messages[i] = SmsMessage.createFromPdu ((byte[])pdusObj[i]); 
                for (SmsMessage currentMessage : messages)
                {   
                    s = currentMessage.getDisplayMessageBody();
                    if(s.contains("VIDEO"))
                    {
                        Intent iAlarm = new Intent( context, CameraPreview.class );
                        iAlarm.addFlags(Intent.FLAG_FROM_BACKGROUND);
                        iAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        context.startActivity(iAlarm);
                    }
                }
            }
        }
    }
}   
</code></pre>

<p>}</p>

<p>but it throws null pointer exception at recorder.setCamera(PREVIEW.mCamera);</p>
