幾天前,我收到了我發佈的應用程序的崩潰日誌。ToneGenerator崩潰Android
錯誤來自ToneGenerator,我找不到問題。
在這裏,我有一個倒數計時器,當計時器達到0時,應用程序啓動ToneGenerator。
private void lanceMinuteur(int temps, int color){
if(color == 0)
minuteur.setTextColor(getResources().getColor(R.color.color_important));
else
minuteur.setTextColor(getResources().getColor(R.color.color_informative));
if(chronoLance){
chrono.cancel();
}
chronoLance = true;
chrono = new CountDownTimer((temps + 1) * 1000, 1000) {
public void onTick(long millisUntilFinished) {
minuteur.setText(String.valueOf(millisUntilFinished/1000) + "\"");
}
public void onFinish() {
minuteur.setText("0\"");
minuteur.setTextColor(getResources().getColor(R.color.textcolor1design));
chronoLance = false;
final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); //The error is coming from here
tg.startTone(ToneGenerator.TONE_PROP_ACK);
}
}.start();
}
而崩潰日誌我收到:
java.lang.RuntimeException: Init failed
at android.media.ToneGenerator.native_setup(Native Method)
at android.media.ToneGenerator.<init>(ToneGenerator.java:798)
at ma.myperf.musculation.activ.GoPerformanceActivity$2.onFinish(GoPerformanceActivity.java:350)
at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4385)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
那麼什麼可以是問題?如果ToneGenerator有一個try Catch塊,但我沒有。
我在想,也許發生崩潰的設備沒有AudioManager.Stream_Notification?
同樣的問題在這裏:(http://stackoverflow.com/questions/13463691/error-generating-beep-using-tonegenerator-class –
你的代碼在'GoPerformanceActivity.java'中,第350行? – dumbfingers
行350是這行最後ToneGenerator tg =新ToneGenerator(AudioManager.STREAM_NOTIFICATION,100);這是我把「//錯誤來自這裏」 – FR073N