Back to project page ITM_Android_App.
The source code is released under:
GNU General Public License
If you think the Android project ITM_Android_App listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * Copyright 2013 Bhavyanshu Parasher * This file is part of "ITM University Android Application". * "ITM University Android Application" is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free Software Foundation, * either version 3 of the License, or (at your option) any later version. * "ITM University Android Application" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with "ITM University Android Application". * If not, see http://www.gnu.org/licenses/. *//* ww w . j ava 2s .c o m*/ /** * Simple connectivity manager for the app. */ package com.wbs.itm; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; public class AppStatus { private static AppStatus instance = new AppStatus(); static Context context; ConnectivityManager connectivityManager; NetworkInfo wifiInfo, mobileInfo; boolean connected = false; public static AppStatus 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; } }