Java tutorial
//package com.java2s; import android.annotation.SuppressLint; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { @SuppressLint("DefaultLocale") public static String getAPN(Context context) { String apn = ""; ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = manager.getActiveNetworkInfo(); if (info != null) { if (ConnectivityManager.TYPE_WIFI == info.getType()) { apn = info.getTypeName(); if (apn == null) { apn = "wifi"; } } else { apn = info.getExtraInfo().toLowerCase(); if (apn == null) { apn = "mobile"; } } } return apn; } }