android - MediaRecorder throw "java.lang.RuntimeException: start failed: -2147483648" when trying to record audio on LG G Watch -
i trying record audio in app on lg g watch. following code throws runtimeexception message "start failed: -2147483648" @ statement "recorder.start();". wondering i'm doing wrong here.
i have tried lot of different set of parameters, example audiosource:
recorder.setaudiosource(mediarecorder.audiosource.default); //-and- recorder.setaudiosource(mediarecorder.audiosource.mic);
also outputformat have tried
recorder.setoutputformat(mediarecorder.outputformat.default); //-and- recorder.setoutputformat(mediarecorder.outputformat.mpeg_4); //-and- recorder.setoutputformat(mediarecorder.outputformat.three_gpp);
also tried different audioencoder
recorder.setaudioencoder(mediarecorder.audioencoder.default); //-and- recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb);
here source code:
final mediarecorder recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.default); recorder.setoutputformat(mediarecorder.outputformat.default); recorder.setaudioencoder(mediarecorder.audioencoder.default); //recorder.setaudiosamplingrate(8000); // tried , without line string filename = mmainactivity.getexternalfilesdir(null) + "/my_recording.mp4"; // changed corresponding extension name output format log.d("debug", "output filename = " + filename); recorder.setoutputfile(filename); try { recorder.prepare(); } catch (ioexception e) { log.d("debug", "ioexception while prepare(): " + e.getmessage()); } try { thread.sleep(1000); } catch (interruptedexception e) { log.d("debug", "interruptedexception while thread.sleep(): " + e.getmessage()); } log.d("debug", "before start"); try { recorder.start(); // <--- exception thrown here } catch (illegalstateexception e) { log.d("debug", "illegalstateexception while start(): " + e.getmessage()); } log.d("debug", "after start");
------------edit--------------------
here logcat output:
09-22 01:33:10.697 8764-8764/com.company.project d/debug﹕ output filename = /storage/emulated/0/android/data/com.company.project/files/my_recording.mp4 09-22 01:33:11.697 8764-8764/com.company.project d/debug﹕ before start 09-22 01:33:11.707 8764-8764/com.company.project e/mediarecorder﹕ start failed: -2147483648 09-22 01:33:11.707 8764-8764/com.company.project d/androidruntime﹕ shutting down vm 09-22 01:33:11.707 8764-8764/com.company.project w/dalvikvm﹕ threadid=1: thread exiting uncaught exception (group=0xada14d70) 09-22 01:33:11.737 8764-8764/com.company.project e/androidruntime﹕ fatal exception: main process: com.company.project, pid: 8764 java.lang.runtimeexception: start failed. @ android.media.mediarecorder.start(native method) @ com.company.project.mainactivity$1.onlayoutinflated(mainactivity.java:56) @ android.support.wearable.view.watchviewstub.inflate(watchviewstub.java:133) @ android.support.wearable.view.watchviewstub.onmeasure(watchviewstub.java:141) @ android.view.view.measure(view.java:16648) @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) @ android.widget.framelayout.onmeasure(framelayout.java:310) @ android.view.view.measure(view.java:16648) @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) @ android.widget.framelayout.onmeasure(framelayout.java:310) @ com.android.internal.policy.impl.phonewindow$decorview.onmeasure(phonewindow.java:2338) @ android.view.view.measure(view.java:16648) @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:1959) @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1145) @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1396) @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1032) @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:5657) @ android.view.choreographer$callbackrecord.run(choreographer.java:761) @ android.view.choreographer.docallbacks(choreographer.java:574) @ android.view.choreographer.doframe(choreographer.java:544) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:747) @ android.os.handler.handlecallback(handler.java:733) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5026) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:777) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:602) @ dalvik.system.nativestart.main(native method) 09-22 01:33:11.777 8764-8764/com.company.project i/process﹕ sending signal. pid: 8764 sig: 9
note: have following permissions in manifest:
<uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.record_audio" />
my environment is:
sdk: api 20: android 4.4 (kitkat wear) build tool: 19.1.0 android studio: 0.8.9
you cannot use mediarecorder in android wear, audiorecord. here youtube video google developers talking how recording audio speech recognition:
Comments
Post a Comment