[회전] 안드로이드 핸드폰 및 심카드 상태 획득

4807 단어 android
TelephonyManager      ,           Sim    。 
         ,   
package net.sunniwell.app;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
public class TelManager extends Activity {
@Override 
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  TelephonyManager tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
  
  /*
   *     :
   * 1.tm.CALL_STATE_IDLE=0               
   * 2.tm.CALL_STATE_RINGING=1       
   * 3.tm.CALL_STATE_OFFHOOK=2    
   */ 
  tm.getCallState(); //int 
  
  /*
   *     :
   */ 
  tm.getCellLocation(); //CellLocation 
  
  /*
   *      ID:
   * GSM    IMEI   CDMA    MEID. 
   * Return null if device ID is not available.
   */ 
  tm.getDeviceId(); //String 
  
  /*
   *         :
   *   :the IMEI/SV(software version) for GSM phones.
   * Return null if the software version is not available. 
   */ 
  tm.getDeviceSoftwareVersion(); //String 
  
  /*
   *    :
   * GSM    MSISDN.
   * Return null if it is unavailable. 
   */ 
  tm.getLine1Number(); //String 
  
  /*
   *         :
   *   :List<NeighboringCellInfo> 
   *     :android.Manifest.permission#ACCESS_COARSE_UPDATES
   */
  tm.getNeighboringCellInfo(); //List<NeighboringCellInfo>
  
  /*
   *   ISO      ,       。
   *   :             。
   *        CDMA          。
   */ 
  tm.getNetworkCountryIso(); //String 
  
  /*
   * MCC+MNC(mobile country code + mobile network code)
   *   :             。
   *     CDMA          。
   */ 
  tm.getNetworkOperator(); //String 
  
  /*
   *        current registered operator(        )   
   *   :             。
   *     CDMA          。
   */ 
  tm.getNetworkOperatorName(); //String 
  
  /*
   *          :
   *   : NETWORK_TYPE_UNKNOWN          0
   * NETWORK_TYPE_GPRS     GPRS    1
   * NETWORK_TYPE_EDGE     EDGE    2
   * NETWORK_TYPE_UMTS     UMTS    3
   * NETWORK_TYPE_HSDPA    HSDPA    8 
   * NETWORK_TYPE_HSUPA    HSUPA    9
   * NETWORK_TYPE_HSPA     HSPA    10
   * NETWORK_TYPE_CDMA     CDMA  ,IS95A   IS95B.  4
   * NETWORK_TYPE_EVDO_0   EVDO  , revision 0.  5
   * NETWORK_TYPE_EVDO_A   EVDO  , revision A.  6
   * NETWORK_TYPE_1xRTT    1xRTT    7
   */ 
  tm.getNetworkType(); //int 
  
  /*
   *     :
   *   : PHONE_TYPE_NONE     
   * PHONE_TYPE_GSM   GSM  
   * PHONE_TYPE_CDMA  CDMA  
   */ 
  tm.getPhoneType(); //int 
  
  /*
   * Returns the ISO country code equivalent for the SIM provider's country code.
   *   ISO   ,     SIM     。
   */ 
  tm.getSimCountryIso(); //String 
  
  /*
   * Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM. 5 or 6 decimal digits.
   *   SIM               .5 6       .
   * SIM        SIM_STATE_READY(  getSimState()  ).
   */ 
  tm.getSimOperator(); //String 
  
  /*
   *      :
   *   :    、  
   * SIM        SIM_STATE_READY(  getSimState()  ).
   */ 
  tm.getSimOperatorName(); //String 
  
  /*
   * SIM     :
   *     :READ_PHONE_STATE
   */ 
  tm.getSimSerialNumber(); //String 
  
  /*
   * SIM     :
   *  SIM_STATE_UNKNOWN                  0
   *  SIM_STATE_ABSENT                     1
   *  SIM_STATE_PIN_REQUIRED         ,     PIN    2
   *  SIM_STATE_PUK_REQUIRED        ,     PUK    3
   *  SIM_STATE_NETWORK_LOCKED       ,     PIN    4
   *  SIM_STATE_READY                 5
   */ 
  tm.getSimState(); //int 
  
  /*
   *      ID:
   *   :IMSI(         ) for a GSM phone.
   *     :READ_PHONE_STATE
   */ 
  tm.getSubscriberId(); //String 
  
  /*
   *             ,     
   *     :READ_PHONE_STATE
   */ 
  tm.getVoiceMailAlphaTag(); //String 
  
  /*
   *         :
   *     :READ_PHONE_STATE
   */ 
  tm.getVoiceMailNumber(); //String 
  
  /*
   * ICC     
   */ 
  tm.hasIccCard(); //boolean 
  
  /*
   *     :
   * ( GSM   )
   */ 
  tm.isNetworkRoaming(); // 
  
}
}

좋은 웹페이지 즐겨찾기