Android examples for Phone:Network
get the current network type
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /**//from w ww .ja v a2 s .c om * get the current network type * @param context * @return */ public static String NetType(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (null == info) return null; String typeName = info.getTypeName().toLowerCase(); if (typeName.equals("wifi")) { } else { typeName = info.getExtraInfo().toLowerCase(); } return typeName; } catch (Exception e) { e.printStackTrace(); return null; } } }