gpt4 book ai didi

android - 为什么我触摸停止按钮,不幸的是我的应用程序关闭了

转载 作者:行者123 更新时间:2023-11-29 21:16:43 25 4
gpt4 key购买 nike

这是我的代码,应用程序在我触摸停止按钮后自动关闭。我调试并跟踪到“myAudioRecorder.stop()”,它有异常“error(s)_during_the_evaluation”。我还不知道如何修复它。

public void stop(View view){

myAudioRecorder.stop();
myAudioRecorder.release();
myAudioRecorder = null;
stop.setEnabled(false);
play.setEnabled(true);
Toast.makeText(getApplicationContext(), "Audio recorded successfully",
Toast.LENGTH_LONG).show();

}

Logcat 结果

01-20 11:24:22.378: D/GraphicBuffer(28301): create handle(0x5caa3400) (w:480, h:800, f:1)
01-20 11:24:22.494: I/SurfaceTextureClient(28301): [STC::queueBuffer] (this:0x5ca90e00) fps:0.07, dur:15218.09, max:15218.09, min:15218.09
01-20 11:24:22.494: I/SurfaceTextureClient(28301): [STC::queueBuffer] this:0x5ca90e00, api:1, last queue time elapsed:15218.09
01-20 11:24:24.732: V/InputMethodManager(28301): onWindowFocus: null softInputMode=32 first=true flags=#1810100
01-20 11:24:24.733: V/InputMethodManager(28301): START INPUT: com.android.internal.policy.impl.PhoneWindow$DecorView{41352438 V.E..... R......D 0,0-480,800} ic=null tba=android.view.inputmethod.EditorInfo@413a5410 controlFlags=#104
01-20 11:24:24.745: D/dalvikvm(28301): threadid=11: interp stack at 0x5e1c8000
01-20 11:24:24.846: V/InputMethodManager(28301): Starting input: Bind result=InputBindResult{null com.vng.inputmethod.labankey/.LatinIME #793}
01-20 11:24:24.848: D/GraphicBuffer(28301): create handle(0x5dc11f30) (w:480, h:800, f:1)
01-20 11:24:24.854: I/SurfaceTextureClient(28301): [STC::queueBuffer] (this:0x5ca90e00) fps:0.42, dur:2359.53, max:2359.53, min:2359.53
01-20 11:24:24.854: I/InputMethodManager(28301): handleMessage: MSG_SET_ACTIVE true, was false
01-20 11:24:25.595: I/View(28301): Touch down dispatch to android.widget.Button{41382718 VFED..C. ........ 88,448-165,520 #7f080002 app:id/button1}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=42.727646, y[0]=22.317139, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=42646762, downTime=42646762, deviceId=5, source=0x1002 }
01-20 11:24:25.611: D/GraphicBuffer(28301): create handle(0x5dc14060) (w:480, h:800, f:1)
01-20 11:24:25.707: I/View(28301): Touch up dispatch to android.widget.Button{41382718 VFED..C. ...P.... 88,448-165,520 #7f080002 app:id/button1}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=42.727646, y[0]=22.317139, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=42646876, downTime=42646762, deviceId=5, source=0x1002 }
01-20 11:24:25.709: V/Provider/Settings(28301): invalidate [system]: current 175 != cached 0
01-20 11:24:25.712: D/ActivityThread(28301): installProvider: context=android.app.ContextImpl@41351618holder=android.app.IActivityManager$ContentProviderHolder@413a9d28noisy=truenoReleaseNeeded=truestable=true
01-20 11:24:25.713: V/Provider/Settings(28301): from db cache, name = sound_effects_enabled , value = 0
01-20 11:24:25.723: W/System.err(28301): java.io.FileNotFoundException: /storage/sdcard0/myrecording.3gp: open failed: EACCES (Permission denied)
01-20 11:24:25.731: W/System.err(28301): at libcore.io.IoBridge.open(IoBridge.java:460)
01-20 11:24:25.731: W/System.err(28301): at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
01-20 11:24:25.731: W/System.err(28301): at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
01-20 11:24:25.732: W/System.err(28301): at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
01-20 11:24:25.732: W/System.err(28301): at android.media.MediaRecorder.prepare(MediaRecorder.java:693)
01-20 11:24:25.732: W/System.err(28301): at com.cuonglm.ghiam.MainActivity.start(MainActivity.java:43)
01-20 11:24:25.732: W/System.err(28301): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 11:24:25.732: W/System.err(28301): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 11:24:25.732: W/System.err(28301): at android.view.View$1.onClick(View.java:3612)
01-20 11:24:25.732: W/System.err(28301): at android.view.View.performClick(View.java:4222)
01-20 11:24:25.732: W/System.err(28301): at android.view.View$PerformClick.run(View.java:17620)
01-20 11:24:25.732: W/System.err(28301): at android.os.Handler.handleCallback(Handler.java:800)
01-20 11:24:25.733: W/System.err(28301): at android.os.Handler.dispatchMessage(Handler.java:100)
01-20 11:24:25.733: W/System.err(28301): at android.os.Looper.loop(Looper.java:194)
01-20 11:24:25.733: W/System.err(28301): at android.app.ActivityThread.main(ActivityThread.java:5409)
01-20 11:24:25.733: W/System.err(28301): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 11:24:25.733: W/System.err(28301): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 11:24:25.733: W/System.err(28301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-20 11:24:25.733: W/System.err(28301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
01-20 11:24:25.734: W/System.err(28301): at dalvik.system.NativeStart.main(Native Method)
01-20 11:24:25.734: W/System.err(28301): Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
01-20 11:24:25.735: W/System.err(28301): at libcore.io.Posix.open(Native Method)
01-20 11:24:25.735: W/System.err(28301): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
01-20 11:24:25.735: W/System.err(28301): at libcore.io.IoBridge.open(IoBridge.java:444)
01-20 11:24:25.736: W/System.err(28301): ... 19 more
01-20 11:24:25.800: D/ServiceManager(28301): The name of the service is notification
01-20 11:24:25.806: D/ServiceManager(28301): The name of the service is power
01-20 11:24:25.850: D/GraphicBuffer(28301): create handle(0x5dc08f80) (w:240, h:77, f:1)
01-20 11:24:29.307: D/GraphicBuffer(28301): close handle(0x5dc08f80) (w:240 h:77 f:1)
01-20 11:24:32.375: I/View(28301): Touch down dispatch to android.widget.Button{41392050 VFED..C. ........ 321,448-396,520 #7f080003 app:id/button2}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=42.243225, y[0]=39.2959, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=42653543, downTime=42653543, deviceId=5, source=0x1002 }
01-20 11:24:32.384: I/SurfaceTextureClient(28301): [STC::queueBuffer] (this:0x5ca90e00) fps:0.40, dur:7530.46, max:6579.88, min:189.37
01-20 11:24:32.384: I/SurfaceTextureClient(28301): [STC::queueBuffer] this:0x5ca90e00, api:1, last queue time elapsed:6579.88
01-20 11:24:32.519: I/View(28301): Touch up dispatch to android.widget.Button{41392050 VFED..C. ...P.... 321,448-396,520 #7f080003 app:id/button2}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=42.243225, y[0]=39.2959, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=42653688, downTime=42653543, deviceId=5, source=0x1002 }
01-20 11:24:32.520: V/Provider/Settings(28301): from settings cache , name = sound_effects_enabled , value = 0
01-20 11:24:32.525: E/MediaRecorder(28301): stop called in an invalid state: 4
01-20 11:24:32.527: D/AndroidRuntime(28301): Shutting down VM
01-20 11:24:32.527: W/dalvikvm(28301): threadid=1: thread exiting with uncaught exception (group=0x40e559a8)
01-20 11:24:32.527: W/dalvikvm(28301): threadid=1: uncaught exception occurred
01-20 11:24:32.527: W/System.err(28301): java.lang.IllegalStateException: Could not execute method of the activity
01-20 11:24:32.528: W/System.err(28301): at android.view.View$1.onClick(View.java:3617)
01-20 11:24:32.528: W/System.err(28301): at android.view.View.performClick(View.java:4222)
01-20 11:24:32.529: W/System.err(28301): at android.view.View$PerformClick.run(View.java:17620)
01-20 11:24:32.529: W/System.err(28301): at android.os.Handler.handleCallback(Handler.java:800)
01-20 11:24:32.529: W/System.err(28301): at android.os.Handler.dispatchMessage(Handler.java:100)
01-20 11:24:32.530: W/System.err(28301): at android.os.Looper.loop(Looper.java:194)
01-20 11:24:32.530: W/System.err(28301): at android.app.ActivityThread.main(ActivityThread.java:5409)
01-20 11:24:32.530: W/System.err(28301): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 11:24:32.531: W/System.err(28301): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 11:24:32.531: W/System.err(28301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-20 11:24:32.531: W/System.err(28301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
01-20 11:24:32.532: W/System.err(28301): at dalvik.system.NativeStart.main(Native Method)
01-20 11:24:32.532: W/System.err(28301): Caused by: java.lang.reflect.InvocationTargetException
01-20 11:24:32.533: W/System.err(28301): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 11:24:32.533: W/System.err(28301): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 11:24:32.534: W/System.err(28301): at android.view.View$1.onClick(View.java:3612)
01-20 11:24:32.534: W/System.err(28301): ... 11 more
01-20 11:24:32.534: W/System.err(28301): Caused by: java.lang.IllegalStateException
01-20 11:24:32.535: W/System.err(28301): at android.media.MediaRecorder.stop(Native Method)
01-20 11:24:32.536: W/System.err(28301): at com.cuonglm.ghiam.MainActivity.stop(MainActivity.java:60)
01-20 11:24:32.536: W/System.err(28301): ... 14 more
01-20 11:24:32.537: W/dalvikvm(28301): threadid=1: calling UncaughtExceptionHandler
01-20 11:24:32.541: E/AndroidRuntime(28301): FATAL EXCEPTION: main
01-20 11:24:32.541: E/AndroidRuntime(28301): java.lang.IllegalStateException: Could not execute method of the activity
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.view.View$1.onClick(View.java:3617)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.view.View.performClick(View.java:4222)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.view.View$PerformClick.run(View.java:17620)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.os.Handler.handleCallback(Handler.java:800)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.os.Handler.dispatchMessage(Handler.java:100)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.os.Looper.loop(Looper.java:194)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.app.ActivityThread.main(ActivityThread.java:5409)
01-20 11:24:32.541: E/AndroidRuntime(28301): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 11:24:32.541: E/AndroidRuntime(28301): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 11:24:32.541: E/AndroidRuntime(28301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-20 11:24:32.541: E/AndroidRuntime(28301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
01-20 11:24:32.541: E/AndroidRuntime(28301): at dalvik.system.NativeStart.main(Native Method)
01-20 11:24:32.541: E/AndroidRuntime(28301): Caused by: java.lang.reflect.InvocationTargetException
01-20 11:24:32.541: E/AndroidRuntime(28301): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 11:24:32.541: E/AndroidRuntime(28301): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.view.View$1.onClick(View.java:3612)
01-20 11:24:32.541: E/AndroidRuntime(28301): ... 11 more
01-20 11:24:32.541: E/AndroidRuntime(28301): Caused by: java.lang.IllegalStateException
01-20 11:24:32.541: E/AndroidRuntime(28301): at android.media.MediaRecorder.stop(Native Method)
01-20 11:24:32.541: E/AndroidRuntime(28301): at com.cuonglm.ghiam.MainActivity.stop(MainActivity.java:60)
01-20 11:24:32.541: E/AndroidRuntime(28301): ... 14 more

最佳答案

java.io.FileNotFoundException: /storage/sdcard0/myrecording.3gp: open failed: EACCES (Permission denied)

您是否已将 WRITE_EXTERNAL_STORAGERECORD_AUDIO 权限插入到应用程序的 list 文件中?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

阅读关于Audio Capture的官方教程.

关于android - 为什么我触摸停止按钮,不幸的是我的应用程序关闭了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21226129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com