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,
Asked
Active
Viewed 5,819 times
4
-
1possible duplicate of [Dual SIM card Android](http://stackoverflow.com/questions/5255147/dual-sim-card-android) – Manoj Kumar Mar 25 '14 at 11:09
-
1Look [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 Answers
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
-
refer this link also..http://stackoverflow.com/questions/38093754/send-sms-using-sim-selection-option# – harikrishnan Jun 29 '16 at 09:08
-
The question is asking **how to send SMS from specific SIM** not to get info about specific SIM! – Choletski Feb 27 '18 at 09:26