Hi,all. The app I wrote doesn't run correctly on the device.Could someone give me a suggestion that how to solution this problem. The code is below. -------------------------------------------------------------------------- MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile("/sdcard/test.amr"); try { recorder.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block Log.e(Tag, "IllegalStateException"); e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block Log.e(Tag, "IOException"); e.printStackTrace(); } recorder.start(); ------------------------------------------------------------------------------------
The log is below. E/AndroidRuntime( 1441): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 1441): java.lang.RuntimeException: setAudioSource failed. E/AndroidRuntime( 1441): at android.media.MediaRecorder.setAudioSource (Native Method) E/AndroidRuntime( 1441): at com.android.RecorderTest.RecorderTest.RecoredInit(RecorderTest.java: 75) E/AndroidRuntime( 1441): at com.android.RecorderTest.RecorderTest.access$0(RecorderTest.java:73) E/AndroidRuntime( 1441): at com.android.RecorderTest.RecorderTest $1.onClick(RecorderTest.java:94) E/AndroidRuntime( 1441): at android.view.View.performClick(View.java: 2346) E/AndroidRuntime( 1441): at android.view.View.onTouchEvent(View.java: 4159) E/AndroidRuntime( 1441): at android.widget.TextView.onTouchEvent (TextView.java:6496) E/AndroidRuntime( 1441): at android.view.View.dispatchTouchEvent (View.java:3691) E/AndroidRuntime( 1441): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:882) E/AndroidRuntime( 1441): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:882) E/AndroidRuntime( 1441): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:882) E/AndroidRuntime( 1441): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:882) E/AndroidRuntime( 1441): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:882) E/AndroidRuntime( 1441): at com.android.internal.policy.impl.PhoneWindow $DecorView.superDispatchTouchEvent(PhoneWindow.java:1712) E/AndroidRuntime( 1441): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1202) E/AndroidRuntime( 1441): at android.app.Activity.dispatchTouchEvent (Activity.java:2014) E/AndroidRuntime( 1441): at com.android.internal.policy.impl.PhoneWindow $DecorView.dispatchTouchEvent(PhoneWindow.java:1696) E/AndroidRuntime( 1441): at android.view.ViewRoot.handleMessage (ViewRoot.java:1626) E/AndroidRuntime( 1441): at android.os.Handler.dispatchMessage (Handler.java:99) E/AndroidRuntime( 1441): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 1441): at android.app.ActivityThread.main (ActivityThread.java:4140) E/AndroidRuntime( 1441): at java.lang.reflect.Method.invokeNative (Native Method) E/AndroidRuntime( 1441): at java.lang.reflect.Method.invoke (Method.java:521) E/AndroidRuntime( 1441): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:782) E/AndroidRuntime( 1441): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:540) E/AndroidRuntime( 1441): at dalvik.system.NativeStart.main(Native Method) W/asset ( 1167): Asset path /data/app/RecorderTest.apk is neither a directory nor file (type=1). W/PackageManager( 1167): Failure retrieving resources forcom.android.RecorderTest --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---