From 478c5f1a6830eed6c627500e1b82373e796f5ef2 Mon Sep 17 00:00:00 2001 From: bezloginu Date: Sun, 2 Jul 2017 10:58:34 +0200 Subject: [PATCH] Catch index out of bound --- .../f1x/mtcdautovolume/MtcdAutoVolumeService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/microntek/f1x/mtcdautovolume/MtcdAutoVolumeService.java b/app/src/main/java/com/microntek/f1x/mtcdautovolume/MtcdAutoVolumeService.java index a8cbf8b..b943a68 100644 --- a/app/src/main/java/com/microntek/f1x/mtcdautovolume/MtcdAutoVolumeService.java +++ b/app/src/main/java/com/microntek/f1x/mtcdautovolume/MtcdAutoVolumeService.java @@ -93,8 +93,12 @@ public int onStartCommand(Intent intent, int flags, int startId) { @Override public void onLocationChanged(Location location) { if(location.hasSpeed() && mAutoVolumeManager.isActive()) { - final int speedKph = (int)((location.getSpeed() * 3600) / 1000); - mAutoVolumeManager.adjustVolumeForSpeed(speedKph); + try { + final int speedKph = (int) ((location.getSpeed() * 3600) / 1000); + mAutoVolumeManager.adjustVolumeForSpeed(speedKph); + } catch(IndexOutOfBoundsException e) { + e.printStackTrace(); + } } }