Android examples for Network:Network Status
get network Proxy
//package com.java2s; import android.content.Context; import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static final String getProxy(Context context) { if (checkPermission(context, "android.permission.ACCESS_NETWORK_STATE")) { return null; }/* w w w .ja va 2 s. com*/ try { ConnectivityManager cConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo cNetworkInfo = cConnectivityManager .getActiveNetworkInfo(); if (cNetworkInfo == null) { return null; } if (cNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) { return null; } String str = cNetworkInfo.getExtraInfo(); if (str == null) return null; if ((str.equals("cmwap")) || (str.equals("3gwap")) || (str.equals("uniwap"))) { return "10.0.0.172"; } } catch (Exception e) { e.printStackTrace(); } return null; } public static final boolean checkPermission(Context context, String premission) { PackageManager localPackageManager = context.getPackageManager(); if (localPackageManager.checkPermission(premission, context.getPackageName()) != android.content.pm.PackageManager.PERMISSION_GRANTED) { return false; } return true; } }