dipanshu jindal
dipanshu jindal

Reputation: 203

How to make Call using specified sim in android like true caller?

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
     startActivity(callIntent);

I want to select sim and call using selected sim in dual sim phone like true caller.Now it always open the Default dialog. If anyone has the solution ,Please help me.

Upvotes: 3

Views: 1177

Answers (1)

Rakesh
Rakesh

Reputation: 552

Below is the code for dual sim calling:

private List<PhoneAccountHandle> phoneAccountHandleList;
int item =0;// 0 for sim1 & 1 for sim2
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"
};


TelecomManager telecomManager = (TelecomManager)this.getSystemService(Context.TELECOM_SERVICE);
phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
Intent intent = new Intent(Intent.ACTION_CALL).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("tel:" + number));
intent.putExtra("com.android.phone.force.slot", true);
intent.putExtra("Cdma_Supp", true);
if (item == 0) {//for sim1
    for (String s : simSlotName){
       intent.putExtra(s, 0); //0 or 1 according to sim.......
    }
    if (phoneAccountHandleList != null && phoneAccountHandleList.size() > 0)
    {
       intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE",      
        phoneAccountHandleList.get(0));
    }
} else {//for sim2
   for (String s : simSlotName) {
       intent.putExtra(s, 1); //0 or 1 according to sim.......
    }
   if (phoneAccountHandleList != null && phoneAccountHandleList.size() > 1){
       intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", 
       phoneAccountHandleList.get(1));
   }
 }
  startActivity(intent);

Upvotes: 4

Related Questions