From 62f5262d8bfa537f2b173c0309f1128054cf0916 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 31 Jul 2013 08:08:27 +0300 Subject: [PATCH] Do not crash when takePicture fails --- src/ro/ieval/fonbot/Heavy.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ro/ieval/fonbot/Heavy.java b/src/ro/ieval/fonbot/Heavy.java index cac04f7..fadf42c 100644 --- a/src/ro/ieval/fonbot/Heavy.java +++ b/src/ro/ieval/fonbot/Heavy.java @@ -58,6 +58,7 @@ import android.os.BatteryManager; import android.os.Bundle; import android.os.Handler; import android.os.PowerManager; +import android.os.SystemClock; import android.os.Vibrator; import android.preference.PreferenceManager; import android.provider.BaseColumns; @@ -1237,16 +1238,16 @@ final class Heavy { new Thread(new Runnable() { @Override public void run() { - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - //ignored - } + SystemClock.sleep(2000); handler.post(new Runnable() { @Override public void run() { - camera.takePicture(null, null, new FonBotPictureCallback(context, replyTo, hostname, port)); + try { + camera.takePicture(null, null, new FonBotPictureCallback(context, replyTo, hostname, port)); + } catch(Exception e){ + Utils.sendMessage(context, replyTo, error_while_processing_command, e.getClass().getName(), e.getMessage()); + } } }); } -- 2.39.2