只需调用您活动的上下文
private voID getNWInfo(Context context) { /** * <uses-permission androID:name="androID.permission.READ_PHONE_STATE" * /> <uses-permission * androID:name="androID.permission.ACCESS_NETWORK_STATE"/> */ TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String networkOperator = telephonyManager.getNetworkOperator(); int mcc = 0,mnc = 0; if (networkOperator != null) { mcc = Integer.parseInt(networkOperator.substring(0,3)); mnc = Integer.parseInt(networkOperator.substring(3)); } String SimNumber = telephonyManager.getline1Number(); String SimserialNumber = telephonyManager.getSimserialNumber(); String countryISO = telephonyManager.getSimCountryIso(); String operatorname = telephonyManager.getSimOperatorname(); String operator = telephonyManager.getSimOperator(); int simstate = telephonyManager.getSimstate(); String voicemailNumer = telephonyManager.getVoiceMailNumber(); String voicemailAlphaTag = telephonyManager.getVoiceMailAlphaTag(); // Getting connected network iso country code String networkCountry = telephonyManager.getNetworkCountryIso(); // Getting the connected network operator ID String networkOperatorID = telephonyManager.getNetworkOperator(); // Getting the connected network operator name String networkname = telephonyManager.getNetworkOperatorname(); int networkType = telephonyManager.getNetworkType(); String network = ""; ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); try { if (cm.getActiveNetworkInfo().getTypename().equals("MOBILE")) network = "Cell Network/3G"; else if (cm.getActiveNetworkInfo().getTypename().equals("WIFI")) network = "WiFi"; else network = "N/A"; } catch (Exception e) { // Todo auto-generated catch block e.printstacktrace(); } TextVIEw textVIEw = (TextVIEw) findVIEwByID(R.ID.textVIEw); textVIEw.setText("network :" + network + "\n" + "countryISO : " + countryISO + "\n" + "operatorname : " + operatorname + "\n" + "operator : " + operator + "\n" + "simstate :" + simstate + "\n" + "Sim Serial Number : " + SimserialNumber + "\n" + "Sim Number : " + SimNumber + "\n" + "Voice Mail Numer" + voicemailNumer + "\n" + "Voice Mail Alpha Tag" + voicemailAlphaTag + "\n" + "Sim State" + simstate + "\n" + "Mobile Country Code MCC : " + mcc + "\n" + "Mobile Network Code MNC : " + mnc + "\n" + "Network Country : " + networkCountry + "\n" + "Network OperatorID : " + networkOperatorID + "\n" + "Network name : " + networkname + "\n" + "Network Type : " + networkType); }
你可以在这个博客上找到更多细节
http://khurramitdeveloper.blogspot.in/search?updated-max=2013-11-07T03:23:00-08:00&max-results=7
希望它会帮助你:)
总结以上是内存溢出为你收集整理的android中的Gsm网络信息全部内容,希望文章能够帮你解决android中的Gsm网络信息所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)