/** * Method that checks whether the server is reachable / available to the application. * * @param activityObj The object of the activity. */ public static boolean RemoteServerIsReachable(Activity activityObj) { try { if (!InetAddress.getByName("http://crazysellout.comule.com").isReachable(2000)) { SystemDialogs.DisplayInformationAlertBox( "The server is not reachable at the moment.\n" + "Please try again later.", "Server Connection", activityObj); return false; } } catch (IOException e) { } return true; }
/** * Method that checks if the wifi of the mobile phone is enabled. If not it calls the error alert * box method to display an error message and exit the application. * * @param activityObj The object of the activity from which the wifi service will be checked. */ public static void WifiEnabledCheck(Activity activityObj) { try { WifiManager mng = (WifiManager) activityObj.getSystemService(Context.WIFI_SERVICE); if (!mng.isWifiEnabled()) { SystemDialogs.DisplayErrorAlertBox( "Your wifi is not enabled!\nPlease turn your wifi on" + " and re-open the application.", "Wifi not enabled", activityObj); } } catch (NullPointerException ex) { throw new NullPointerException(); } catch (ClassCastException ex) { throw new ClassCastException(); } }