From 1660fd76d2c85b82996bc0d0ecdd43f7ae9d33fd Mon Sep 17 00:00:00 2001 From: dewall Date: Fri, 3 Jun 2016 15:32:50 +0200 Subject: [PATCH] fixed unusual bug where some android versions cannot initialize voice output --- .../app/services/OBDConnectionService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/org.envirocar.app/src/org/envirocar/app/services/OBDConnectionService.java b/org.envirocar.app/src/org/envirocar/app/services/OBDConnectionService.java index 68c3de812..82f162d5e 100644 --- a/org.envirocar.app/src/org/envirocar/app/services/OBDConnectionService.java +++ b/org.envirocar.app/src/org/envirocar/app/services/OBDConnectionService.java @@ -146,11 +146,15 @@ public void onCreate() { mTTS = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { - if (status == TextToSpeech.SUCCESS) { - mIsTTSAvailable = true; - mTTS.setLanguage(Locale.ENGLISH); - } else { - LOG.warn("TextToSpeech is not available."); + try { + if (status == TextToSpeech.SUCCESS) { + mTTS.setLanguage(Locale.ENGLISH); + mIsTTSAvailable = true; + } else { + LOG.warn("TextToSpeech is not available."); + } + } catch(IllegalArgumentException e){ + LOG.warn("TextToSpeech is not available"); } } });