hi Ben, by using you code, I encountered the problem, “The application audiorecorder(process com.david.android.audiorecorder) has stopped unexpectedly. Please try again”.
My audiorecoder class looks like as: import android.app.Activity; import android.os.Bundle; //importing yours … public class audiorecorder extends Activity { //then following your codes … } Below is the Logcat info: D/AndroidRuntime( 815): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< D/AndroidRuntime( 815): CheckJNI is ON D/AndroidRuntime( 815): — registering native functions — I/jdwp ( 815): received file descriptor 25 from ADB I/ActivityManager( 56): Starting activity: Intent { flags=0×10000000 comp={com.david.android.audiorecorder/com.david.android.audiorecorder.audiorecorder} } I/ActivityManager( 56): Start proc com.david.android.audiorecorder for activity com.david.android.audiorecorder/.audiorecorder: pid=824 uid=10040 gids={} D/AndroidRuntime( 815): Shutting down VM D/dalvikvm( 815): DestroyJavaVM waiting for non-daemon threads to exit D/dalvikvm( 815): DestroyJavaVM shutting VM down D/dalvikvm( 815): HeapWorker thread shutting down D/dalvikvm( 815): HeapWorker thread has shut down D/jdwp ( 815): JDWP shutting down net… D/jdwp ( 815): +++ peer disconnected I/dalvikvm( 815): Debugger has detached; object registry had 1 entries D/dalvikvm( 815): VM cleaning up D/dalvikvm( 815): LinearAlloc 0×0 used 594756 of 4194304 (14%) I/jdwp ( 824): received file descriptor 10 from ADB D/dalvikvm( 824): newInstance failed: no () D/AndroidRuntime( 824): Shutting down VM W/dalvikvm( 824): threadid=3: thread exiting with uncaught exception (group=0×4000fe68) E/AndroidRuntime( 824): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 824): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.david.android.audiorecorder/com.david.android.audiorecorder.audiorecorder}: java.lang.InstantiationException: com.david.android.audiorecorder.audiorecorder E/AndroidRuntime( 824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2082) E/AndroidRuntime( 824): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2172) E/AndroidRuntime( 824): at android.app.ActivityThread.access$1800(ActivityThread.java:112) E/AndroidRuntime( 824): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1586) E/AndroidRuntime( 824): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 824): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 824): at android.app.ActivityThread.main(ActivityThread.java:3790) E/AndroidRuntime( 824): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 824): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745) E/AndroidRuntime( 824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:503) E/AndroidRuntime( 824): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 824): Caused by: java.lang.InstantiationException: com.david.android.audiorecorder.audiorecorder E/AndroidRuntime( 824): at java.lang.Class.newInstanceImpl(Native Method) E/AndroidRuntime( 824): at java.lang.Class.newInstance(Class.java:1458) E/AndroidRuntime( 824): at android.app.Instrumentation.newActivity(Instrumentation.java:1097) E/AndroidRuntime( 824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) E/AndroidRuntime( 824): … 11 more I/Process ( 56): Sending signal. PID: 824 SIG: 3 I/dalvikvm( 824): threadid=7: reacting to signal 3 I/dalvikvm( 824): Wrote stack trace to ‘/data/anr/traces.txt’ W/InputManagerService( 56): Starting input on non-focused client android.view.inputmethod.inputmethodmanage...@43704540 (uid=1000 pid=56) W/InputManagerService( 56): Ignoring focus gain of: android.view.inputmethod.inputmethodmanage...@43704540 W/ActivityManager( 56): Launch timeout has expired, giving up wake lock! W/ActivityManager( 56): Activity idle timeout for HistoryRecord{43852e68 {com.david.android.audiorecorder/com.david.android.audiorecorder.audiorecorder}} D/dalvikvm( 100): GC freed 1763 objects / 93784 bytes in 135ms I/Process ( 824): Sending signal. PID: 824 SIG: 9 I/ActivityManager( 56): Process com.david.android.audiorecorder (pid 824) has died. D/InputManagerService( 56): hide the small icon for the input method V/ActivityThread( 100): Resuming ActivityRecord{436cc620 token=android.os.binderpr...@436cc0b0{com.android.launcher/com.android.launcher.Launcher}} with isForward=false I’m sorry if this mess-like info toubles again because I issued it at https://mail.google.com/mail/?hl=en&zx=1mf4sjv3oovlo&shva=1#starred/11fd8b68c28f154b. Could your please help me figure out what’s the real reason causing this problem? Thanks a lot. david 2009/3/12 benmccann <benjamin.j.mcc...@gmail.com> > > Finally got it figured out: > http://www.benmccann.com/dev-blog/android-audio-recording-tutorial/ > > On Mar 9, 11:37 am, benmccann <benjamin.j.mcc...@gmail.com> wrote: > > I'm still feeling directionless when it comes to what > > MediaRecorder.setOutputFile(String path) is expecting. Is it a > > relative path? Is it a fully qualified path? Must the directory we > > are recording in already exist, or will MediaRecorder create it for us > > if it does not exist? What happens if we specify a file path which > > already exists - will it override the existing file or will it bomb > > out? > > > > On Mar 7, 10:30 pm, benmccann <benjamin.j.mcc...@gmail.com> wrote: > > > > > jdl, I'd be happy to post my code, but I still don't have a working > > > example. I upgraded to the 1.1 SDK today in hopes that it fixed a bug > > > and things would work for me, but it seems the media APIs are still > > > hopelessly broken. All I ever get is the meaningless message "start > > > failed". It looks like perhaps the cause is a buffer overflow in the > > > native code: > > > > > 03-07 21:19:42.059: DEBUG/AudioHardware(25): AudioStreamInGeneric::set > > > (0xac50, 7, 1, 1, 8000) > > > 03-07 21:19:42.069: DEBUG/AudioHardware(25): AudioStreamInGeneric::read > > > (0x40308020, 320) from fd 7 > > > 03-07 21:19:42.078: DEBUG/AudioHardware(25): AudioStreamInGeneric::read > > > (0x40308160, 320) from fd 7 > > > 03-07 21:19:42.078: DEBUG/AudioHardware(25): AudioStreamInGeneric::read > > > (0x403082a0, 320) from fd 7 > > > 03-07 21:19:42.078: DEBUG/AudioHardware(25): AudioStreamInGeneric::read > > > (0x403083e0, 320) from fd 7 > > > 03-07 21:19:42.088: WARN/AudioFlinger(25): AudioRecordThread: buffer > > > overflow > > > 03-07 21:19:42.098: DEBUG/AndroidRuntime(185): Shutting down VM > > > 03-07 21:19:42.098: WARN/dalvikvm(185): threadid=3: thread exiting > > > with uncaught exception (group=0x4000fe68) > > > 03-07 21:19:42.098: ERROR/AndroidRuntime(185): Uncaught handler: > > > thread main exiting due to uncaught exception > > > 03-07 21:19:42.128: DEBUG/AudioHardware(25): AudioStreamInGeneric::read > > > (0x40308020, 320) from fd 7 > > > 03-07 21:19:42.128: DEBUG/AudioHardware(25): AudioStreamInGeneric::read > > > (0x40308160, 320) from fd 7 > > > 03-07 21:19:42.128: ERROR/AndroidRuntime(185): > > > java.lang.RuntimeException: start failed. > > > 03-07 21:19:42.128: ERROR/AndroidRuntime(185): at > > > android.media.MediaRecorder.start(Native Method) > > > 03-07 21:19:42.128: ERROR/AndroidRuntime(185): at > > > com.benmccann.android.hello.AudioRecorder.start(AudioRecorder.java:59) > > > 03-07 21:19:42.128: ERROR/AndroidRuntime(185): at > > > com.benmccann.android.hello.HelloAndroid$1.onClick(HelloAndroid.java: > > > 31) > > > > > On Mar 6, 1:38 pm, benmccann <benjamin.j.mcc...@gmail.com> wrote: > > > > > > Bugs already exist: > http://code.google.com/p/android/issues/detail?id=450&q=media%20docum.... > .. > > > > > > On Mar 5, 9:23 pm, Dave Sparks <davidspa...@android.com> wrote: > > > > > > > Log a bug athttp://b.android.com. > > > > > > > On Mar 5, 2:17 pm, jdl <j...@edufone.com> wrote: > > > > > > > > Diane or Dave, > > > > > > > > How do we go about requesting that someone from the Android > project > > > > > > update the Audio/Video tutorial, > http://developer.android.com/guide/topics/media/index.html, > > > > > > so that it works with the current version of the API? > > > > > > > > Thanks, > > > > > > AN > > > > > > > > On Feb 28, 2:45 pm, Dianne Hackborn <hack...@android.com> wrote: > > > > > > > > > You use Context to get at your private data files: > > > > > > > > > > http://developer.android.com/guide/topics/data/data-storage.html > > > > > > > > > > http://developer.android.com/reference/android/content/Context.html#g...) > > > > > > > > > On Thu, Feb 26, 2009 at 2:40 PM, benmccann < > benjamin.j.mcc...@gmail.com>wrote: > > > > > > > > > > >> each application has its own private data directory / > > > > > > > > >> data/app-private/app-package. I believe your working > directory is set > > > > > > > > >> to this directory by default > > > > > > > > > > Cool. So it sounds like I should just be able to use a > relative path > > > > > > > > from the current location then. Unfortunately, I'm getting > the > > > > > > > > following exception (with no clues as to why start is > failing): > > > > > > > > > > 02-26 14:34:55.132: ERROR/AndroidRuntime(164): > > > > > > > > java.lang.RuntimeException: start failed. > > > > > > > > 02-26 14:34:55.132: ERROR/AndroidRuntime(164): at > > > > > > > > android.media.MediaRecorder.start(Native Method) > > > > > > > > > > Here's my code: > > > > > > > > > > final MediaRecorder recorder = new MediaRecorder(); > > > > > > > > recorder.setAudioSource(MediaRecorder.AudioSource.MIC); > > > > > > > > > recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); > > > > > > > > > recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); > > > > > > > > recorder.setOutputFile("test.3gpp"); > > > > > > > > recorder.prepare(); > > > > > > > > recorder.start(); > > > > > > > > > > On Feb 26, 12:14 am, Dave Sparks <davidspa...@android.com> > wrote: > > > > > > > > > You can get the path to external storage (e.g. SD card) > with > > > > > > > > > Environment.getExternalStorageDirectory(). This is world > read/ > > > > > > > > > writable. > > > > > > > > > > > Alternatively, each application has its own private data > directory / > > > > > > > > > data/app-private/app-package. I believe your working > directory is set > > > > > > > > > to this directory by default. This is onboard flash, so it > will > > > > > > > > > survive the user ejecting an SD card. However, there is a > limited > > > > > > > > > amount to go around, so you don't want to store monster > media files > > > > > > > > > there. > > > > > > > > > > > On Feb 25, 9:22 pm, benmccann <benjamin.j.mcc...@gmail.com> > wrote: > > > > > > > > > > > > >> setOutputFile() expects a path to where you want the > file stored. > > > > > > > > > > > > Yep, figured that much by the method name, but what's a > valid path? I > > > > > > > > > > mean I'm figuring it's UNIX-like, but other than that I'm > in the > > > > > > > > > > dark. Is there a preferred place for apps to store data? > Are there > > > > > > > > > > certain directories that I have permission to write to? > What > > > > > > > > > > directories exist on the device by default? It'd be nice > for the docs > > > > > > > > > > on data storage to mention any of these things: > > > > > > > > > http://developer.android.com/guide/topics/data/data-storage.html > > > > > > > > > > > > >> You can take a look at the source to SoundRecorder in > the open > > > > > > > > source tree for some working code > > > > > > > > > > > > Thanks for the example. This would be a much better > example than the > > > > > > > > > > one in the docs that won't compile and implies content > must first be > > > > > > > > > > added to a database: > > > > > > > >http://developer.android.com/guide/topics/media/index.html > > > > > > > > > > > > On Feb 24, 8:03 pm, Dave Sparks <davidspa...@android.com> > wrote: > > > > > > > > > > > > > setOutputFile() expects a path to where you want the > file stored. > > > > > > > > > > > > > You can take a look at the source to SoundRecorder in > the open source > > > > > > > > > > > tree for some working code: > > > > > > > > > > > http://android.git.kernel.org/?p=platform/packages/apps/SoundRecorder... > > > > > > > > > > > > > On Feb 24, 4:43 pm, benmccann < > benjamin.j.mcc...@gmail.com> wrote: > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > I'd like to create anaudiorecordingin Android. > (Actually, I just > > > > > > > > > > > > want access to the mic withoutrecordingit, but it > seems that's not > > > > > > > > > > > > supported so I'll have to create arecordingand tail > the file). > > > > > > > > > > > > I'm having a very hard time getting started. Mostly > I'm just > > > > > > > > hoping > > > > > > > > > > > > that someone from Google reads this and will update > the > > > > > > > > documentation > > > > > > > > > > > > because the example won't compile - it looks like > it's from some > > > > > > > > > > > > previous version of the SDK because there's an error > in every other > > > > > > > > > > > > line. I made my best guess as to what the usage > should be, but I > > > > > > > > keep > > > > > > > > > > > > getting a number of different exceptions. > > > > > > > > > > > > One question I had is whether I can just specify an > arbitrary path > > > > > > > > to > > > > > > > > > > > > the MediaRecorder to startrecordingor whether I have > to create an > > > > > > > > > > > > entry in the content database. The JavaDoc for > > > > > > > > > > > > MediaRecorder.setOutputFile isn't clear on what it's > expecting. > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Ben > > > > > > > > > -- > > > > > > > Dianne Hackborn > > > > > > > Android framework engineer > > > > > > > hack...@android.com > > > > > > > > > Note: please don't send private questions to me, as I don't > have time to > > > > > > > provide private support. All such questions should be posted > on public > > > > > > > forums, where I and others can see and answer them. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---