Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use TelephonyManager.</p> <p><a href="http://developer.android.com/reference/android/telephony/TelephonyManager.html" rel="noreferrer">http://developer.android.com/reference/android/telephony/TelephonyManager.html</a> </p> <p>As Falmarri notes, you <em>will</em> want to use <em>getPhoneType</em> FIRST of all, to see if you are even dealing with a GSM phone. If you are, then you can also get the SIM state. </p> <pre><code>TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); int simState = telMgr.getSimState(); switch (simState) { case TelephonyManager.SIM_STATE_ABSENT: // do something break; case TelephonyManager.SIM_STATE_NETWORK_LOCKED: // do something break; case TelephonyManager.SIM_STATE_PIN_REQUIRED: // do something break; case TelephonyManager.SIM_STATE_PUK_REQUIRED: // do something break; case TelephonyManager.SIM_STATE_READY: // do something break; case TelephonyManager.SIM_STATE_UNKNOWN: // do something break; } </code></pre> <hr> <p><strong>EDIT:</strong></p> <p>Starting at API 26 (<em>Android O Preview</em>) you can query the SimState for individual sim slots by using <code>getSimState(int slotIndex)</code> ie:</p> <pre><code>int simStateMain = telMgr.getSimState(0); int simStateSecond = telMgr.getSimState(1); </code></pre> <p><a href="https://developer.android.com/reference/android/telephony/TelephonyManager.html#getSimState(int)" rel="noreferrer">official documentation</a></p> <p>If you're developing with and older api, you can use <code>TelephonyManager's</code></p> <pre><code>String getDeviceId (int slotIndex) //returns null if device ID is not available. ie. query slotIndex 1 in a single sim device int devIdSecond = telMgr.getDeviceId(1); //if(devIdSecond == null) // no second sim slot available </code></pre> <p>which was added in API 23 - docs <a href="https://developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId(int)" rel="noreferrer">here</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload