Sms Manager For Dual Sim Phones?
Solution 1:
This Will work for both scenario. If Already user has been selected the default sim it will automatically takes that and goto the next process, Otherwise while click on the send button it will ask the confirmation for choose any sim to send the sms. we have tested its working fine.
Sample Source Code:
try
{
IntentsendIntent=newIntent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body","Body");
sendIntent.putExtra("address", "PhoneNumber");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
}
catch (Exception e)
{
Toast.makeText(getApplicationContext(),"SMS faild, please try again later!",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
Solution 2:
sendTextMessage()
has the scAddress
parameter. This is used to define the SMS center address. I think if you set it correctly, you'll be able to send a message.
You can find the number by following this tutorial: http://algorithmic-indian.blogspot.hu/2011/03/how-to-change-message-center-number-in.html You may try this as well how to get the smsc number of a phone in android? Apparently there doesn't seem to be a way to programmatically get the number.
Solution 3:
Try this code for sim selection, then use SMS sending method to send an SMS!
//above Android API 22if (Build.VERSION.SDK_INT > 22) {
//for dual sim mobileSubscriptionManagerlocalSubscriptionManager= SubscriptionManager.from(this);
if (localSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
//if there are two sims in dual sim mobileListlocalList= localSubscriptionManager.getActiveSubscriptionInfoList();
SubscriptionInfosimInfo= (SubscriptionInfo) localList.get(0);
SubscriptionInfosimInfo1= (SubscriptionInfo) localList.get(1);
finalStringsim1= simInfo.getDisplayName().toString();
finalStringsim2= simInfo1.getDisplayName().toString();
}else{
//if there is 1 sim in dual sim mobileTelephonyManagertManager= (TelephonyManager) getBaseContext()
.getSystemService(Context.TELEPHONY_SERVICE);
Stringsim1= tManager.getNetworkOperatorName();
}
}else{
//below android API 22TelephonyManagertManager= (TelephonyManager) getBaseContext()
.getSystemService(Context.TELEPHONY_SERVICE);
Stringsim1= tManager.getNetworkOperatorName();
}
Post a Comment for "Sms Manager For Dual Sim Phones?"