Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android dual SIM card API

There are several questions about accessing dual SIM features through the Android SDK, all of which are answered with brief statements that such features are unsupported in Android.

In spite of this, dual SIM phones do exist, and applications like MultiSim seem to be able to detect this in some kind of manufacturer-independent way.

So, beginning with that acknowledgement, let me try to ask some more pointed questions:

  • Does "Android SDK does not support multiple SIM features" mean that these features do not exist, or that it is merely a bad idea to try to use them?
  • Is there an Android content provider or an internal package (com.android...) that provides SIM card information? (TelephonyManager, as far as I can see in the docs and the code, has no mention of multiple SIM cards)
  • Is there any report of any manufacturer exposing multiple SIM features to developers?
  • If I were to look for undocumented functionality from a manufacturer, how would I go about that?

(By the way, the point of all of this is merely to implement this algorithm: send an SMS with SIM card 1; if delivery fails, switch to SIM card 2 and resend the message that way.)

like image 846
adam.baker Avatar asked Jul 03 '12 06:07

adam.baker


People also ask

Can 2 SIM cards be active at once?

A Dual SIM Passive phone can use two different SIM cards, but only one of them can be active at any time. That means that when one SIM card works, the other is unreachable. To use the second SIM card, you need to activate it manually, and the first SIM deactivates when you do that.

How can you tell if someone has two SIM cards?

To see if the phone your using is dual-SIM, go into your phone's Settings app. Tap on Network and internet. The SIM cards option should be right below Airplane mode. If you see that the option shows you two slots for a SIM card, your phone is Dual-SIM.

What is Android Telephony API?

telephony. Kotlin |Java. Provides APIs for monitoring the basic phone information, such as the network type and connection state, plus utilities for manipulating phone number strings.


2 Answers

You can use MultiSim library to get details from multi-sim devices.

Available info from each sim card: IMEI, IMSI, SIM Serial Number, SIM State, SIM operator code, SIM operator name, SIM country iso, network operator code, network operator name, network operator iso, network type, roaming status.

Just add the lines below in your app-level Gradle script:

dependencies {     compile 'com.kirianov.multisim:multisim:2.0@aar' } 

Don't forget add required permission in AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

Use similar code in your code:

MultiSimTelephonyManager multiSimTelephonyManager = new MultiSimTelephonyManager(this); // or MultiSimTelephonyManager multiSimTelephonyManager = new MultiSimTelephonyManager(this, new BroadcastReceiver() {   @Override   public void onReceive(Context context, Intent intent) {     updateInfo();   } });   public void updateInfo() {    // for update UI   runOnUiThread(new Runnable() {     @Override     public void run() {       multiSimTelephonyManager.update();       useInfo();     }   }    // for update background information   multiSimTelephonyManager.update();   useInfo(); }  public void useInfo() {    // get number of slots:   if (multiSimTelephonyManager != null) {      multiSimTelephonyManager.sizeSlots();   }    // get info from each slot:   if (multiSimTelephonyManager != null) {     for(int i = 0; i < multiSimTelephonyManager.sizeSlots(); i++) {       multiSimTelephonyManager.getSlot(i).getImei();       multiSimTelephonyManager.getSlot(i).getImsi();       multiSimTelephonyManager.getSlot(i).getSimSerialNumber();       multiSimTelephonyManager.getSlot(i).getSimState();       multiSimTelephonyManager.getSlot(i).getSimOperator();       multiSimTelephonyManager.getSlot(i).getSimOperatorName();       multiSimTelephonyManager.getSlot(i).getSimCountryIso();       multiSimTelephonyManager.getSlot(i).getNetworkOperator();       multiSimTelephonyManager.getSlot(i).getNetworkOperatorName();       multiSimTelephonyManager.getSlot(i).getNetworkCountryIso();       multiSimTelephonyManager.getSlot(i).getNetworkType();       multiSimTelephonyManager.getSlot(i).isNetworkRoaming();     }   } }  // or for devices above android 6.0 MultiSimTelephonyManager multiSimTelephonyManager = new MultiSimTelephonyManager(MyActivity.this, broadcastReceiverChange); 

Usage:

// get info about slot 'i' by methods: multiSimTelephonyManager.getSlot(i). 

Force update info:

// force update phone info (needed on devices above android 6.0 after confirm permissions request) multiSimTelephonyManager.update(); 

Handle of permissions request (6.0+):

// in YourActivity for update info after confirm permissions request on  devices above android 6.0 @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {     super.onRequestPermissionsResult(requestCode, permissions, grantResults);     if (multiSimTelephonyManager != null) {         multiSimTelephonyManager.update();     } } 
like image 63
Tapa Save Avatar answered Sep 29 '22 13:09

Tapa Save


there are 3 different categories ...

  1. features supported and documented
  2. Features available and un-documented
  3. features unavailable

So the dual sim features are available but not documented and hence not officially supported.

Having said that it doesn't mean that it will not be usable , It just means that android(or for that matter google or even manufaturer) is not liable to support your apps functionality.

But it might just work , for eg the contacts is a similar thing.

You might then ask up how would everyone know about the features if in case its not documented.. Hey android is open source .. go look into code and find it for yourself . Thats what I guess the multi sim developers did.

like image 39
Gaurav Shah Avatar answered Sep 29 '22 13:09

Gaurav Shah