I wrote a code that sends SMS to a specific number, but it works on current phones with 1 SIM card, how to make it so that you can also send SMS from a dual SIM ... can you say let's say sending from the first SIM, or from two at once ..

public class MainActivity extends AppCompatActivity { Button button; EditText edittext; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.button); edittext = (EditText) findViewById(R.id.text); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String number = "номер телефона"; String text = "текст"; SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(number,null,text,null,null); } }); } } 

    2 answers 2

    I met such an example, but did not check the performance.

     Runtime.getRuntime().exec("service call isms 5 s16 "number" i32 0 i32 0 s16 "body"\n"); 

    We get a bonus with the ability to send SMS from another isms2 slot, the list of available ones can be checked in the output of the service list command

    • those. This line should be added instead of smsmanager or added to it ??? - Aram Mucho Gevorgyan
    • The code I gave is a Shell command that sends SMS from the 1st SIM slot. - Magic

    Himself faced with such a problem. There is not much information on Ineta. Maybe someone will come in handy

    Today I found 2 ways - The first one is as described here.

      try { Runtime.getRuntime().exec("service call isms 5 s16 " + phoneNumber + " i32 0 i32 0 s16 " + message + "\n"); } catch (IOException e) { e.printStackTrace(); } 

    The second option is in the SIM card settings? choose to send SMS to this or that card

    In the first option, you specify the SIM card programmatically? And in the second case, manually in the phone settings