Android Viewing System Information

Source: Internet
Author: User

1. How to use Android.os.SystemProperties


The Android system implements the creation, acquisition, and modification of system properties, primarily through the Systemproperties class, which is called directly locally.

Systemproperties class under Android.os, the path is:

/frameworks/base/core/java/android/os/systemproperties.java

The Systemproperties class is under Android.os, but the class is hidden and the upper-level program development cannot be used directly.


Android.os.SystemProperties is not in the library of the SDK and needs to be

Android Sdk\platforms\android-xx\data\layoutlib.jar

The file is added to the additional library path of the current project and can be import in the source program.


However, adding external jars method in Java Build path->libraries cannot be added directly

Copy the Layoutlib.jar file to the project root first, then right-click Build Path-->add to build Path is OK


Get System Properties:

Android.os.SystemProperties.get ("Ro.build.version.sdk")

Where key value is in the Android source directory

Android\platform\out\target\product\mt8658sdk\system\build.prop

In the file

# begin build properties# autogenerated by buildinfo.shro.build.id= Imm76lro.build.version.incremental=eng.****.20140829.161823ro.build.version.sdk=15ro.build.version.codename= relro.build.version.release=4.0.4ro.build.date=2014  08 month  29 day   Friday  16:18:59  cstro.build.date.utc=1409300339ro.build.type=engro.build.user=*****ro.build.host=iptv-intro.build.tags= dev-keysro.wifi.channels=# ro.build.product is obsolete; use ro.product.device#  do not try to parse ro.build.description or . fingerprintro.build.characteristics=defaultpersist.sys.country=uspersist.sys.language=esro.product.hwversion= YMB. A202. aro.product.swversion=001.006.711ro.product.swversion.num=001006711# end build properties##  additional_build_properties#ro.com.android.dateformat=mm-dd-yyyyro.config.ringtone=ring_synth_04. Oggro.config.notification_sound=pixiedust.oggro.config.alarm_alert=alarm_claSsic.oggwifi.interface=wlan0 



Special properties:


If the property name is "Ro." Begins, then this property is treated as a read-only property. Once set, the property value cannot be changed.


If the property name is "persist." At the beginning, when this property is set, its value is also written to/data/property.


If the property name is in "net." At the beginning, when this property is set, the "Net.change" property is automatically set to add to the last modified property name.


When setting properties, be aware that:

Android.os.SystemProperties.set (Key, Val)

Where the name prefix of the key value must be used

Android\platform\system\core\init

The program that is defined in the system property must also have the systems or root permissions

How do I elevate the permissions of Android programs to system permissions? Here's how it's done:

1. In Androidmanifest.xml, join in Manifest

Android:shareduserid= "Android.uid.system"

2, in the ANDROID.MK, will

Local_certificate: = XXX

Modified into

Local_certificate: =platform



2.TelephonyManager Get Mobile Information


       TelephonyManager tm =  (Telephonymanager)   This.getsystemservice (telephony_service);/* *  phone Status:  1.tm. call_state_idle=0  no active  2.tm. call_state_ringing=1  Bell  * 3.tm. call_state_offhook=2  Off-Hook  */tm.getcallstate ();// int/* *  Telephone Directions:  */ Tm.getcelllocation ();// celllocation/* *  unique device id: gsm mobile phone's  IMEI  and &NBSP;CDMA phone's  meid. return null if device id is not * available. */ Tm.getdeviceid () The software version number of the;// string/* *  device:  for example: THE&NBSP;IMEI/SV (software version)   For gsm phones. return * null if the software version is  not available. */tm.getdevicesoftwareversion ();// string/* *  mobile phone number:  gsm  msisdn. return null if it is unavailable. */tm.getline1number ();//& NBsP string/* *  near the phone information:  type:list<neighboringcellinfo> *  requires permission: Android. Manifest.permission#access_coarse_updates */tm.getneighboringcellinfo ();// list< neighboringcellinfo>/* *  obtains the ISO standard country code, namely the international long distance code.   NOTE: Only if the user has been registered with the network.   results in a CDMA network may not be reliable.  */tm.getnetworkcountryiso ();//&NBSP;STRING/*&NBSP;*&NBSP;MCC+MNC (mobile country code +  mobile network code)   NOTE: Only valid if the user is registered with the network.  *  results in a CDMA network may not be reliable.  */tm.getnetworkoperator ();// string/* *  in alphabetical order Current registered operator ( The name of the currently registered user)   NOTE: Only if the user is already active on the network registration.  *  results in a CDMA network may not be reliable.  */tm.getnetworkoperatorname ();// string/* *  The type of network currently in use:  for example:  network_type_unknown   Network type unknown &NBSP;0&NBSP;NETWORK_TYPE_GPRS&NBSP;GPRS network  * 1 network_type_edge edge network  2 &NBSP;NETWORK_TYPE_UMTS&NBSP;UMTS Network &NBSP;3&NBSP;*&NBSP;NETWORK_TYPE_HSDPA&NBSP;HSDPA Network  8 network_ Type_hsupa&nbsP HSUPA Network &NBSP;9&NBSP;*&NBSP;NETWORK_TYPE_HSPA&NBSP;HSPA Network &NBSP;10&NBSP;NETWORK_TYPE_CDMA&NBSP;CDMA Network, IS95A   or &NBSP;IS95B.&NBSP;4&NBSP;*&NBSP;NETWORK_TYPE_EVDO_0&NBSP;EVDO network, revision 0. 5  NETWORK_TYPE_EVDO_A&NBSP;EVDO Network,  * revision a. 6 network_type_1xrtt 1xrtt Network  7 */tm.getnetworktype ();// int/* *  phone type:  For example: phone_type_none  no signal &NBSP;PHONE_TYPE_GSM&NBSP;GSM Signal &NBSP;PHONE_TYPE_CDMA&NBSP;*&NBSP;CDMA signal  */tm.getphonetype ();// int/*  * Returns the ISO country code equivalent for the SIM  Provider ' s * country code.  obtains the ISO country code, which is equivalent to the country code providing the SIM card.  */tm.getsimcountryiso ();// string/* * returns the mcc+mnc  (mobile  Country code + mobile network code)  of * the provider of  the sim. 5 or 6 decimal digits. *  Get the mobile country Code and mobile network code provided by the SIM card. A decimal number of 5 or 6 bits. The status of the  sim card must be  * sim_state_ready (using Getsimstate ()).  */ Tm.getsimoperator ();// string/* *  service name:  For example: China Mobile, Unicom  sim card status must be  sim_state_ready ( Use Getsimstate () to determine).  */tm.getsimoperatorname ();// string/* * sim card's serial number:  requires permission: READ_PHONE _state */tm.getsimserialnumber (); Status information: sim_state_unknown  unknown state of// string/* * sim  0 SIM_STATE_ABSENT  No card  1 * SIM_STATE_PIN_REQUIRED  lock status, requires user PIN code to unlock  2  SIM_STATE_PUK_REQUIRED *  lock status, requires the user's PUK code unlock  3 SIM_STATE_NETWORK_LOCKED  lock State, Requires network pin unlock  4 * SIM_STATE_READY  ready status  5 */tm.getsimstate ();// int/* *   Unique user id:  for example: IMSI (International Mobile User ID)  for a GSM phone.  requires permission: read_phone_state */ Tm.getsubscriberid ();// string/* *  get the label associated with the voice mail, that is, the identifier   need permission: read_phone_state */ Tm.getvoicemailalphatag ();/ string/* *  Get voice mail number:  need permission: Read_phone_state */tm.getvoicemailnumber ();// String Whether the/*&NBSP;*&NBSP;ICC card exists  */tm.hasicccard ();// boolean/* *  whether roaming:  (under GSM use)  */ Tm.isnetworkroaming ();



Android Viewing System Information

Related Article

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.