Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
567 views
in Technique[技术] by (71.8m points)

android - Make call using a specified SIM in a Dual SIM Device

I have been searching for this from past few days and I came to know that:

"Dual SIM is not supported in Android out of the box. It is a custom modification by manufacturers, and there is no public API to control it."

There is a solution provided in the below link but its not working on my phone Samsung Galaxy S4 Mini.

Call from second sim

I also found this link, which I found very informative.

http://www.devlper.com/2010/06/using-android-telephonymanager/

Now I know that using the following code, I might have a chance to get lucky to make it working:

Intent callIntent = new Intent(Intent.ACTION_CALL)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        callIntent.setData(Uri.parse("tel:" + phone));
        context.startActivity(callIntent);
callIntent.putExtra("com.android.phone.extra.slot", 0); //For sim 1
and
callIntent.putExtra("com.android.phone.extra.slot", 1); //For sim 2

I am not sure about this, but I have a question.

In Settings under the SIM Card Manager section, when I have to choose a preferred SIM card for Voice Call, I get four options:

  1. Current Network
  2. Ask Always
  3. SIM 1
  4. SIM 2

When I choose Ask Always option then before making a call I am always asked for choosing a SIM Card, displayed in a Dialog Box, to make the call. My question is can I exploit this thing in my App where I press a button to make a call but it always asks me the same way it does when I chose Ask Always option.

I am sorry, I made this question lengthy, but I think it required it. Please help and big thanks in advance.

EDIT:

How can I achieve this, everytime I press any button (Kind of similar to Ask Always option in Settings) : Select SIM Dialog Box

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Code:

private final static String simSlotName[] = {
        "extra_asus_dial_use_dualsim",
        "com.android.phone.extra.slot",
        "slot",
        "simslot",
        "sim_slot",
        "subscription",
        "Subscription",
        "phone",
        "com.android.phone.DialingMode",
        "simSlot",
        "slot_id",
        "simId",
        "simnum",
        "phone_type",
        "slotId",
        "slotIdx"
};


Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "any number"));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("com.android.phone.force.slot", true);
    intent.putExtra("Cdma_Supp", true);
    //Add all slots here, according to device.. (different device require different key so put all together)
    for (String s : simSlotName)
        intent.putExtra(s, 0); //0 or 1 according to sim.......

    //works only for API >= 21
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", (Parcelable) " here You have to get phone account handle list by using telecom manger for both sims:- using this method getCallCapablePhoneAccounts()");

    context.startActivity(intent);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...