public void connectionClosedOnError(Exception e) { Log.e("ConListener", "connectionClosedOnError"); if (!service.isAuthenticated()) Notify.offlineNotify(context, "Connection closed"); if (!isStarted) { isStarted = true; context.sendBroadcast(new Intent(Constants.UPDATE)); Log.e("ConListener", "Trying to connect"); new Thread() { public void run() { while (!service.isAuthenticated(account)) { service.reconnect(account); try { Thread.sleep(30000); } catch (Exception ignored) { } } isStarted = false; } }.start(); } }