is Connected Mobile Network - Android android.net

Android examples for android.net:ConnectivityManager

Description

is Connected Mobile Network

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;

public class Main {

  public static boolean isConnectedMobileNetwork() {
    boolean kResult = false;

    try {/*from  ww  w  .  j av  a  2s.com*/
      ConnectivityManager connectivityManager = (ConnectivityManager) ContextUtil.CONTEXT
          .getSystemService(Context.CONNECTIVITY_SERVICE);
      kResult = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return kResult;
  }

}

Related Tutorials