This topic describes how to get SIM state and subscribe to SIM state changes.
Subscribe
to SIMStateListener
using SIMState.subscribeListener()
method.
//Sample code to subscribe to SIM state changes try { SIMState.subscribeListener(this); } catch (Exception e) { }
Implement
the SIMStateListener
interface by defining the SIMStateListener.SIMStateChanged()
method.
// Sample code implementing the SIMStateListener interface public void SIMStateChanged(int simIndex, int state) { form.append("SIM card state on slot " + simIndex + " is " + state); }
Get the
SIM state of the SIM card in the first slot by calling the SIMState.getState()
method.
//Sample code to get the SIM state of the SIM card in the first slot SIMState.getState(0);