/** Closes an HttpClient. */ public static void close(HttpClient client) { // AndroidHttpClient is available on all platform releases, // but is hidden until API Level 8 try { Class<?> clazz = client.getClass(); Method method = clazz.getMethod("close", (Class<?>[]) null); method.invoke(client, (Object[]) null); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }