4

I have trying to develop an android app which sending SMS to target. if there are two SIM (SIM1, SIM2) card how can I detect them and select specific SIM card to send SMS Thanks,

RealDream
  • 407
  • 3
  • 6
  • 18
  • 1
    possible duplicate of [Dual SIM card Android](http://stackoverflow.com/questions/5255147/dual-sim-card-android) – Manoj Kumar Mar 25 '14 at 11:09
  • 1
    Look [here](http://stackoverflow.com/questions/5255147/dual-sim-card-android) and [here](http://stackoverflow.com/questions/19557147/send-sms-with-second-sim-card-by-android-on-samsung-duos) – Manoj Kumar Mar 25 '14 at 11:10

2 Answers2

1

Please try this code. using Android sdk 5.1 and above.

String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";

PendingIntent localPendingIntent1 = PendingIntent.getBroadcast(mContext, 0, new Intent(this.SENT), 0);
PendingIntent localPendingIntent2 = PendingIntent.getBroadcast(mContext, 0, new Intent(this.DELIVERED), 0);

SubscriptionManager localSubscriptionManager = SubscriptionManager.from(mContext);
if (localSubscriptionManager.getActiveSubscriptionInfoCount() > 1)
{
List localList = localSubscriptionManager.getActiveSubscriptionInfoList();
final String[] arrayOfString = new String[localList.size()];
int i = 0;
Iterator localIterator = localList.iterator();
while (localIterator.hasNext())
{
SubscriptionInfo localSubscriptionInfo = (SubscriptionInfo)localIterator.next();
localSubscriptionInfo.getSubscriptionId();
//log.d("22 api level ", "got dual sim: ");
int j = i + 1;
arrayOfString[i] = (localSubscriptionInfo.getCarrierName().toString() + " " + localSubscriptionInfo.getNumber());
i = j;
}

SmsManager.getDefault().sendTextMessage(paramString1, null, paramString2, localPendingIntent1, localPendingIntent2);
harikrishnan
  • 1,985
  • 4
  • 32
  • 63
-1

in MTK platform you can use :

SmsManagerEx.getDefault().sendTextMessage(serverAddress, null,
                    textMessage, pendingIntent, null, mSIM);
mehdi
  • 340
  • 4
  • 17
amit
  • 1
  • 1