public static boolean isUserLogged(Context context) { AppData.defaultUser = new EvercamAccount(context).getDefaultUser(); if (AppData.defaultUser != null) { AppData.evercamCameraList = new DbCamera(context).getCamerasByOwner(AppData.defaultUser.getUsername(), 500); API.setUserKeyPair(AppData.defaultUser.getApiKey(), AppData.defaultUser.getApiId()); return true; } return false; }
/** * Check the API key and ID is valid or not * * <p>In case the key and ID has already changed by Evercam system */ public static boolean isApiKeyExpired(String username, String apiKey, String apiId) { try { API.setUserKeyPair(apiKey, apiId); new User(username); } catch (EvercamException e) { if (e.getMessage().equals(Constants.API_MESSAGE_UNAUTHORIZED) || e.getMessage().equals(Constants.API_MESSAGE_INVALID_API_KEY)) { return true; } } return false; }