Get Telephonymanager:
Telephoneymanager Tmanager = (telephonymanager) getsystem.service (Contex.telephony_service);
Get network and SIM card information:
public class Mainactivity extends Activity {ListView ShowView; String statusnames[]; arraylist<string> statusvalues = new arraylist<string> (), @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main);// Gets the Telephonymanager object of the system Telephonymanager Tmanager = (telephonymanager) getsystemservice (Context.telephony_service) ;//Gets an array of various state names Statusnames = Getresources (). Getstringarray (r.array.statusnames);//Gets an array representing the status of the SIM card string[] Simstate = Getresources (). Getstringarray (r.array.simstate);//Get an array representing the type of telephone network string[] Phonetype = Getresources (). Getstringarray (r.array.phonetype);//Get the device number Statusvalues.add (Tmanager.getdeviceid ());//Get the version of the system platform Statusvalues.add ( Tmanager.getdevicesoftwareversion ()! = null? Tmanager.getdevicesoftwareversion (): "Unknown");//Get Network Operator Code Statusvalues.add (Tmanager.getnetworkoperator ());// Get the network operator name Statusvalues.add (Tmanager.getnetworkoperatorname ());//Get the phone network type Statusvalues.add (phonetype[ Tmanager.getphonEType ()]);//Gets the location of the device Statusvalues.add (tmanager.getcelllocation ()! = null? tmanager.getcelllocation (). toString (): " Statusvalues.add (Tmanager.getsimcountryiso ());//Obtain the SIM card serial number Statusvalues.add ( Tmanager.getsimserialnumber ());//Get SIM card status Statusvalues.add (Simstate[tmanager.getsimstate ());// Get the ListView Object ShowView = (ListView) Findviewbyid (R.id.show); arraylist<map<string, string>> status = new arraylist<map<string, string>> ();// Iterates through the Statusvalues collection, encapsulates statusnames, statusvalues//data into List<map<string, string>> collection for (int i = 0; i < Statusvalues.size (); i++) {hashmap<string, string> map = new hashmap<string, string> (); Map.put ("name", Statusnames[i]); Map.put ( "Value", Statusvalues.get (i)); Status.add (map);} Use Simpleadapter to encapsulate list data Simpleadapter adapter = new Simpleadapter (this, status, R.layout.line,new string[] {"Name", "V Alue "}, new int[] {r.id.name,r.id.value});//Set Adaptershowview.setadapter for ListView (Adapter);}}
<!--add permission to access your phone's location-- <uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/> <!--add permission to access phone status-- <uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>
Android------phone manager telephonymanager