@@ -0,0 +1,1431 @@
+package fr.pdegand.android.snippets;%0A%0Aimport android.content.Context;%0Aimport android.net.ConnectivityManager;%0Aimport android.net.NetworkInfo;%0Aimport android.net.wifi.WifiManager;%0A%0A/**%0A * Special network snippets%0A */%0Apublic class NetworkSnippets %7B%0A%0A    /**%0A     * Check if the network is available and connected %3Cbr /%3E%0A     * %3Cem%3EBe sure to add android.permission.ACCESS_NETWORK_STATE to your manifest before using this%3C/em%3E%0A     *%0A     * @param context any app/ui context%0A     * @return true if the network is active and connected, false otherwise%0A     */%0A    public static boolean isNetworkAvailable(Context context) %7B%0A        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);%0A        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();%0A        return activeNetworkInfo != null && activeNetworkInfo.isConnected();%0A    %7D%0A%0A    /**%0A     * Check if the Wifi is enabled or not %3Cbr /%3E%0A     * %3Cem%3EBe sure to add android.permission.ACCESS_NETWORK_STATE and android.permission.ACCESS_WIFI_STATE to your manifest before using this%3C/em%3E%0A     *%0A     * @param context any app/ui context%0A     * @return true if the wifi is enabled, false otherwise%0A     */%0A    public static boolean isWifiEnabled(Context context) %7B%0A        WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);%0A        return wifi.isWifiEnabled();%0A    %7D%0A%0A%7D%0A

Add network snippets