2

I had problems to get data about Dual Sim android phones, but it was possible through reflection of specific implementations of Telephonymanager class by each manufacturer.

Now that I have the Dual Sim data I want to send a message through a specific Sim card using SmsManager. However I wasn't able to do that so far. Can someone help me? Does anyone know an approach for doing that?

luizlouro
  • 61
  • 1
  • 6
  • 1
    AFAIK android doesnot support dual sim so the api's assume single sim dual sim mobiles in the market are redesigned for the functionality – Illegal Argument Apr 16 '15 at 10:59
  • Maybe [this](http://stackoverflow.com/questions/14276328/sms-manager-for-dual-sim-phones#18124041) will help. – Exception Apr 16 '15 at 11:07
  • Thanks, but I need to send a message without opening other apps and only programmatically. I need something like *sendTextMessage(..., simCardSlotId )* . I wonder how the native message app is able to send a message using a specific sim card. – luizlouro Apr 16 '15 at 12:31
  • take a look on my solution. it may solve your issue : http://stackoverflow.com/a/30677542/2267723 – Maher Abuthraa Jun 06 '15 at 00:13

1 Answers1

0

Just pass sender Phone Number and Sms Text you want to send to this metthod

public void sendSMS(String phoneNo, String msg) {

    try {

        String SENT = "sent";
        String DELIVERED = "delivered";

        Intent sentIntent = new Intent(SENT);
        /* Create Pending Intents */
        PendingIntent sentPI = PendingIntent.getBroadcast(mContext, 0, sentIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        Intent deliveryIntent = new Intent(DELIVERED);

        PendingIntent deliverPI = PendingIntent.getBroadcast(mContext, 0, deliveryIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        /* Send SMS */
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(phoneNo, null, msg, sentPI, deliverPI);
    } catch (Exception ex) {

        ex.printStackTrace();
    }

}
Rishi Paul
  • 936
  • 2
  • 8
  • 25
  • Thanks, but the Phone Number you should pass to *sendTextMessage()* is the destination address not the sender. – luizlouro Apr 16 '15 at 12:25