I am working on an Android auto-start app that\'s basically dependent on SIM card state. When my app auto starts I need it to check where the SIM card has been changed or n
Do you try your app on android emulator? Maybe you must try your application on android phone directly, i think the android emulator cannot support your application.
Below code will help you to fetch the SIM Serial No
TelephonyManager mTelephonyMgr =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String sSimSerial = mTelephonyMgr.getSimSerialNumber();
Set the following permission on Android Manifest file
android.permission.READ_PHONE_STATE
If you want to react to a Sim change you need to set a listener:
final TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
tm.listen(new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
//Code in here executed on Sim State change
}
@Override
public void onDataConnectionStateChanged(int state) {
}