public void updateHAPPBolus() { List<Treatment> treatments = Treatment.getToUpdateHAPP(); Log.d("UPDATE HAPP:", treatments.size() + " treatments"); for (Treatment bolus : treatments) { ObjectToSync bolusSync = new ObjectToSync(bolus, null); Message msg = Message.obtain(); Bundle bundle = new Bundle(); bundle.putString("ACTION", "bolus_delivery"); bundle.putString("UPDATE", bolusSync.asJSONString()); msg.setData(bundle); try { Log.d("UPDATE HAPP:", "HAPP INT ID " + bolusSync.happ_integration_id); myService.send(msg); } catch (RemoteException e) { e.printStackTrace(); Log.d("UPDATE HAPP:", "Update FAILED for " + bolusSync.happ_integration_id); } finally { Log.d("UPDATE HAPP:", "Update sent for " + bolusSync.happ_integration_id); bolus.happ_update = false; bolus.save(); } } try { if (isBound) IncomingService.this.unbindService(myConnection); } catch (IllegalArgumentException e) { // catch if service was killed in a unclean way } }