gpt4 book ai didi

android - 10 秒后 MediaRecorder.finalize() 中的 TimeoutException

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:13 26 4
gpt4 key购买 nike

stacktrace0=java.util.concurrent.TimeoutException:
android.media.MediaRecorder.finalize() timed out after 10
seconds
at android.media.MediaRecorder.native_finalize(Native Method)
at android.media.MediaRecorder.finalize(MediaRecorder.java:1200)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
at java.lang.Thread.run(Thread.java:841)

if (isDirectoryExists)
{
MediaRecorder recorder= new MediaRecorder();
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.setMaxDuration(30*60*1000);

if(recorder!=null)
{
recorder.prepare();
}
try
{
if(recorder!=null)
{
recorder.start();
isRecordingStarted=true;
}
}
catch (IllegalStateException ilse)
{
try
{
if(recorder!=null)
{
recorder.prepare();
}
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
if(recorder!=null)
{
recorder.start();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

详细:这个问题主要出现在android 4.3当我们再次准备并开始时第一次发生异常媒体记录器。这个逻辑在 4.0 中成功工作..我不明白为什么会出现这种异常。

最佳答案

似乎如果设备决定休眠,而 GC 决定运行,那么就会发生这种情况。

见下文:

Sometimes (very rarely) the System will decide to Sleep in the middleof the GC run.

If the sleep time was long - over 10 seconds, the concurrent.timeout exception will be thrown.

How to handle :java.util.concurrent.TimeoutException: android.os.BinderProxy.finalize() timed out after 10 seconds errors?

关于android - 10 秒后 MediaRecorder.finalize() 中的 TimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22294016/

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