Mar*_*ark 25 android text-to-speech
我得到的报道称,在一些(并非所有)HTC Desire HD(FRF91,2.2)和HTC EVO 4G(PC36100 | 3.29.651.5,2.2)上,TextToSpeech.OnInitListener.onInit(int)被重复调用(在少数几个空间内超过1500次)秒)在同一个对象上.任何我的其他用户(或与其他Desire HD用户)AFAICT不会发生此问题.
代码是:
TextToSpeech tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
private int mCallCount = 0; // trying to investigate potential infinite loops
@Override
public void onInit(int status) {
if ((mCallCount % 100) == 1) {
// report this
}
mCallCount++;
}
});
Run Code Online (Sandbox Code Playgroud)
任何想法?
编辑:我也试过调用该shutdown()方法(第一次检测到多个侦听器调用)但这似乎没有帮助.
也许您应该使用自己的中间方法来解决它,例如:
private long lastCall = 0;
private long deepBreath = 5*1000; //5 seconds
private boolean hasRested;
TextToSpeech tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
long thisCall = Calendar.getInstance().getTimeInMillis();
intermediaryMethod(status, thisCall);
}
});
//new method
public void intermediaryMethod(int status, long thisCall) {
hasRested = (thisCall-lastCall)>=deepBreath;
if (hasRested) {
lastCall = thisCall;
//do something about 'status'
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6946 次 |
| 最近记录: |