Android examples for Hardware:Device Feature
Return if the device is on the internet
//package com.java2s; import android.content.Context; import android.content.ContextWrapper; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /**/*from www.j a v a2 s . c o m*/ * Return if the device is on the internet * @param contextWrapper * @return */ public static boolean isOnline(ContextWrapper contextWrapper) { ConnectivityManager cm = (ConnectivityManager) contextWrapper .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnected(); } }