Simple record to obtain Base Station Information

Source: Internet
Author: User
Tags aliyun

It was written by reference to others' articles before it was very early. Record here.

Public int cellid; // the base station number Public String mobilecountrycode; // The China Mobile country code is 460 public string mobilenetworkcode; // The China Mobile Network number moves 0, China Unicom 1, china Telecom 2 Public int locationareacode; // location region code Public String radiotype; // network standard public int RSSI; // base station signal strength static networkinfo smnetworkinfo = NULL; public static networkinfo getnetworkinfo () {If (smnetworkinfo = NULL) {smnetworkinfo = new networkinfo ();} return smnetworkinfo;} public void ca Ncel () {If (smnetworkinfo! = NULL) {smnetworkinfo = NULL;} public void upload () {log. D ("network info ", cellid + "--" + mobilecountrycode + "--" + mobilenetworkcode + "--" + locationareacode + "--" + radiotype + "--" + Arg);} public void getnetworkinfo () {// todo auto-generated method stubarraylist <networkinfo> Infos = new arraylist <networkinfo> (); telephonymanager mtelephonymanager = (telephonymanager) gpsapplication. getappcontext (). getsystemservice (context. telephony_service); networkinfo currentinfo = new networkinfo (); int type = mtelephonymanager. getnetworktype (); // gsmif (type = telephonymanager. network_type_gprs | type = telephonymanager. network_type_edge | type = telephonymanager. network_type_hsdpa) {log. D ("networkinfo", "GSM location"); gsmcelllocation = (gsmcelllocation) mtelephonymanager. getcelllocation (); If (gsmcelllocation = NULL) {return;} int LAC = gsmcelllocation. getlac (); string MCC = mtelephonymanager. getnetworkoperator (). substring (0, 3); string MNC = mtelephonymanager. getnetworkoperator (). substring (3, 5); currentinfo. cellid = gsmcelllocation. getcid (); currentinfo. mobilecountrycode = MCC; currentinfo. export enetworkcode = MNC; currentinfo. locationareacode = LAC; currentinfo. radiotype = "GSM"; Infos. add (currentinfo); // obtain the base station information list <neighboringcellinfo> List = mtelephonymanager. getneighboringcellinfo (); For (INT I = 0; I <list. size (); I ++) {networkinfo info = new networkinfo (); info. cellid = List. get (I ). getcid (); info. mobilecountrycode = MCC; info. mobilenetworkcode = MNC; info. locationareacode = LAC; info. radiotype = "GSM"; info. http: // service.ap-southeast-1.maxcompute.aliyun-inc.com/api. get (I ). getarg (); Infos. add (Info) ;}/// Telecom CDMA else if (type = telephonymanager. network_type_cdma | type = telephonymanager. network_type_1xrtt | type = telephonymanager. network_type_evdo_0 | type = telephonymanager. network_type_evdo_a) {cdmacelllocation CDMA = (cdmacelllocation) mtelephonymanager. getcelllocation (); int LAC = CDMA. getnetworkid (); string MCC = mtelephonymanager. getnetworkoperator (). substring (0, 3); string MNC = string. valueof (CDMA. getsystemid (); int cid = CDMA. getbasestationid (); currentinfo. cellid = CID; currentinfo. mobilecountrycode = MCC; currentinfo. export enetworkcode = MNC; currentinfo. locationareacode = LAC; currentinfo. radiotype = "CDMA"; Infos. add (currentinfo); // obtain the information list of neighboring base stations <neighboringcellinfo> List = mtelephonymanager. getneighboringcellinfo (); int size = List. size (); For (INT I = 0; I <size; I ++) {networkinfo info = new networkinfo (); info. cellid = List. get (I ). getcid (); info. mobilecountrycode = MCC; info. mobilenetworkcode = MNC; info. locationareacode = LAC; info. http: // service.ap-southeast-1.maxcompute.aliyun-inc.com/api. get (I ). getarg (); Infos. add (Info) ;}}for (INT I = 0; I <Infos. size (); I ++) {Infos. get (I ). upload ();}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.