[Android Software/Hacking General [Developers Only]] teddyyyy123:
I'm a completely new android developer, just trying to get myself familiar with the basic concepts while creating something with a little practical use. thanks in advance for your time.

I'm trying to take a video longer than the default 30-minute limit. basically I'm trying to write an app that loops over taking a video. concept is simple.

I copy-pasted some code from the web, now basically has a SurfaceView implementation, like

public void surfaceCreated(SurfaceHolder holder) {

// The Surface has been created, acquire the camera and tell it where

// to draw.

camera = Camera.open();

recorder = new MediaRecorder();

try {

camera.setPreviewDisplay(holder);

Log.w("after recorder", "");

recorder.setCamera(camera);

recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);

recorder.setOutputFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/yyvideo/aaa.3gp");

recorder.setPreviewDisplay(mHolder.getSurface());

recorder.prepare();

Log.w("after prepare", "okok");

and then I have an activity:

public class Yyandroid2Activity extends Activity {

// private static final String TAG = "MyActivity";

private static final String TAG = "CameraDemo";

// Camera camera;

Preview preview;

Button buttonClick;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

preview = new Preview(this);

((FrameLayout) findViewById(R.id.preview)).addView(preview);

buttonClick = (Button) findViewById(R.id.buttonClick);

buttonClick.setOnClickListener( new OnClickListener() {

private boolean state_on = false;

public void onClick(View v) {

if ( ! state_on ) {

preview.camera.unlock();

preview.recorder.start();

but it gave the following exceptions

10-23 16:38:54.893: W/System.err(666): at android.app.ActivityThread.main(ActivityThread.java:3683)

10-23 16:38:54.903: W/System.err(666): at java.lang.reflect.Method.invokeNative(Native Method)

10-23 16:38:54.903: W/System.err(666): at java.lang.reflect.Method.invoke(Method.java:507)

10-23 16:38:54.903: W/System.err(666): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

10-23 16:38:54.903: W/System.err(666): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

10-23 16:38:54.903: W/System.err(666): at dalvik.system.NativeStart.main(Native Method)

10-23 16:39:01.424: E/MediaRecorder(666): start called in an invalid state: 4

10-23 16:39:01.424: D/AndroidRuntime(666): Shutting down VM

10-23 16:39:01.424: W/dalvikvm(666): threadid=1: thread exiting with uncaught exception (group=0x40015560)

10-23 16:39:01.474: E/AndroidRuntime(666): FATAL EXCEPTION: main

10-23 16:39:01.474: E/AndroidRuntime(666): java.lang.IllegalStateException

10-23 16:39:01.474: E/AndroidRuntime(666): at android.media.MediaRecorder.start(Native Method)

10-23 16:39:01.474: E/AndroidRuntime(666): at yy.android.Yyandroid2Activity$4.onClick(Yyandroid2Activity.java:147)

10-23 16:39:01.474: E/AndroidRuntime(666): at android.view.View.performClick(View.java:2485)

10-23 16:39:01.474: E/AndroidRuntime(666): at android.view.View$PerformClick.run(View.java:9080)

10-23 16:39:01.474: E/AndroidRuntime(666): at android.os.Handler.handleCallback(Handler.java:587)

10-23 16:39:01.474: E/AndroidRuntime(666): at android.os.Handler.dispatchMessage(Handler.java:92)

10-23 16:39:01.474: E/AndroidRuntime(666): at android.os.Looper.loop(Looper.java:123)

10-23 16:39:01.474: E/AndroidRuntime(666): at android.app.ActivityThread.main(ActivityThread.java:3683)

10-23 16:39:01.474: E/AndroidRuntime(666): at java.lang.reflect.Method.invokeNative(Native Method)

10-23 16:39:01.474: E/AndroidRuntime(666): at java.lang.reflect.Method.invoke(Method.java:507)

10-23 16:39:01.474: E/AndroidRuntime(666): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

10-23 16:39:01.474: E/AndroidRuntime(666): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

10-23 16:39:01.474: E/AndroidRuntime(666): at dalvik.system.NativeStart.main(Native Method)

10-23 16:39:03.514: I/Process(666): Sending signal. PID: 666 SIG: 9

any idea where the error is?

Thanks a lot

Yang