Back to project page swap.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project swap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.solazo.swap; //from w w w . j ava2 s. c o m import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; public class AppState { private static AppState instance = new AppState(); static Context context; ConnectivityManager connectivityManager; NetworkInfo wifiInfo, mobileInfo; boolean connected = false; public static AppState getInstance(Context ctx) { context = ctx; return instance; } public boolean isOnline(Context con) { try { connectivityManager = (ConnectivityManager) con .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); connected = networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected(); return connected; } catch (Exception e) { System.out.println("CheckConnectivity Exception: " + e.getMessage()); Log.v("connectivity", e.toString()); } return connected; } }