mirror of
https://github.com/danog/termux-api.git
synced 2025-01-22 21:31:10 +01:00
Support multiple recipients when sending SMS
This commit is contained in:
parent
151717e2fb
commit
a83a77c508
@ -15,11 +15,20 @@ public class SmsSendAPI {
|
||||
@Override
|
||||
public void writeResult(PrintWriter out) throws Exception {
|
||||
final SmsManager smsManager = SmsManager.getDefault();
|
||||
String recipientExtra = intent.getStringExtra("recipient");
|
||||
if (recipientExtra == null) {
|
||||
TermuxApiLogger.error("No 'recipient' extra");
|
||||
String[] recipients = intent.getStringArrayExtra("recipients");
|
||||
|
||||
if (recipients == null) {
|
||||
// Used by old versions of termux-send-sms.
|
||||
String recipient = intent.getStringExtra("recipient");
|
||||
if (recipient != null) recipients = new String[]{recipient};
|
||||
}
|
||||
|
||||
if (recipients == null || recipients.length == 0) {
|
||||
TermuxApiLogger.error("No recipient given");
|
||||
} else {
|
||||
smsManager.sendTextMessage(recipientExtra, null, inputString, null, null);
|
||||
for (String recipient : recipients) {
|
||||
smsManager.sendTextMessage(recipient, null, inputString, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user