Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get both sim numbers in a dual sim android phone

Tags:

I want to get both the sim numbers in a dual sim device.

like image 960
unflagged.destination Avatar asked Nov 20 '12 12:11

unflagged.destination


People also ask

Can you receive calls from both SIMs on a Dual SIM phone?

You can receive calls and messages to both SIM cards. Before you can use the SIM cards, you have to enable them in the Dual SIM settings menu. Data traffic can only be handled on one SIM card at a time and you can select which SIM card you want to use.


1 Answers

Work with API > 21

Need permission android.Manifest.permission.READ_PHONE_STATE.

public class SplahActivity extends AppCompatActivity {

    private Context context;
    private SubscriptionManager mSubscriptionManager;

    public static boolean isMultiSimEnabled = false;
    public static String defaultSimName;

    public static List<SubscriptionInfo> subInfoList;
    public static ArrayList<String> Numbers;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        setContentView(R.layout.activity_splah);

        Numbers = new ArrayList<String>();
        mSubscriptionManager = SubscriptionManager.from(context);
        GetCarriorsInformation();

    }

    private void GetCarriorsInformation() {
        subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
        if (subInfoList.size() > 1) {
            isMultiSimEnabled = true;
        }
        for (SubscriptionInfo subscriptionInfo : subInfoList) {
            Numbers.add(subscriptionInfo.getNumber());
        }
    }
}

SubscriptionManager Api 22 Android Official

like image 153
Sohail Zahid Avatar answered Sep 23 '22 00:09

Sohail Zahid