How to send text message to more than 1 number?
You can't do this via Intent, as the android SMS app doesn't allow multiple recipients.
You can try using the SmsManager
class.
First of all you need to request the permission android.permission.SEND_SMS
in your AndroidManifest.
Then you can do something along these lines.
// you need to import the Sms Manager
import android.telephony.SmsManager;
// fetch the Sms Manager
SmsManager sms = SmsManager.getDefault();
// the message
String message = "Hello";
// the phone numbers we want to send to
String numbers[] = {"555123456789", "555987654321"};
for(String number : numbers) {
sms.sendTextMessage(number, null, message, null, null);
}
Update: Added how to split a comma-separated string
// string input by a user
String userInput = "122323,12344221,1323442";
// split it between any commas, stripping whitespace afterwards
String numbers[] = userInput.split(", *");
Not able to send sms in loop properly, sending multiple sms to single person by mistake
May be you should add a condition for studentId or StudentNo in this Sql Statement.
using (SqlCommand GetAbsentCmd = new SqlCommand("select mobile from studentattendance where convert(varchar(10), attdate, 120) = '" + TodaysDate + "' and attendance='Absent'", GetAbsentCon))
Best way to send multiple SMS at one click using SMS Gateway
my solution was this:
--page /sendsms/?phone_nr=1122 sends one sms to phone nr 1122
--page /sendbulk has a loop which calls in php the page /sendsms/?phone_nr=1122 with file function file('http://www.domain.com//sendsms/?phone_nr=' . $phone_nr[$i]);
--the client on submit will call with ajax(no return needed) the page /sendbulk
This way even if the client closes the connection the server will continue to run /sendbulk in background and will send all messages
Related Topics
Android: Can You Nest Fragments
Dex Error on Android Studio 3.0 Beta4
Phonegap - Forcing Landscape Orientation
Android Remove Space Between Tabs in Tabwidget
How to Solve the Install_Failed_Dexopt Error
Emulator in Android Studio Doesn't Start
When to Register/Unregister Broadcast Receivers Created in an Activity
Android M Camera Intent + Permission Bug
Error: Could Not Find Com.Google.Gms:Google-Services:4.2.0
Firebase Overwrites Signin with Google Account
Adding an Onclicklistener to Listview (Android)
Google Play Services Out of Date. Requires 3159100 But Found 3158130
Calling Setcontentview() Multiple Times
Blur Background Behind Alertdialog
Nullpointerexception When Trying to Access Views in a Kotlin Fragment