title: Android - How to place a call through specific sim in dual sim phone?
body: <p>I am not able to set the default sim for calling. I am trying to alter the system settings to change the default sim every before I sent the ACTION_CALL intent but ever time I am getting the sim selection dialog</p>
  
  <pre><code>public class CallUtil {
  
  public static void sendCallIntent(Context context, String number) {
      Intent intent = new Intent(Intent.ACTION_CALL)
              .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.setData(Uri.parse("tel:" + number));
  
      setDefaultSim(context);
      if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
          return;
      }
      context.startActivity(intent);
  }
  
  public static void setDefaultSim(Context context) {
      try {
          ContentValues val = new ContentValues();
          List&lt;Integer&gt; sims = getInsertedSIMIds(context);
          val.put("value", sims.get(0));
          context.getContentResolver().update(Uri.parse("content://settings/system"), val, "name='voice_call_sim_setting'", null);
  
      } catch (Exception e) {
  
      }
  
  }
  
  public static List&lt;Integer&gt; getInsertedSIMIds(Context context){
      List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
      SubscriptionManager  sm=(SubscriptionManager)context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
      for ( SubscriptionInfo sub: sm.getActiveSubscriptionInfoList()) {
          list.add(sub.getSimSlotIndex());
      }
      return list;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My intention is to place the call through a specific sim using Android 5.1 APIs. Please let me know if there is any alternate approach.</p>