How can my Android Processing app send SMS from the Android device?
@rajiv.tctech===
in order to do that there are several solutions: eg you can create an instance of smsManager and send your message(text message) to some phone number:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(telNumero, null, myMessage, null, null);
or you can do that with an intent and using the built in sms with ACTION_VIEW:
Intent mySmsIntent = new Intent(Intent.ACTION_VIEW);
mySmsIntent.setData(Uri.parse("smsto:"));//nothing to change
mySmSIntent.setType("vnd.android-dir/mms-sms");//nothing to change
mySmsIntent.putExtra("address" , new String("0123456789;9876543210"));//phone(s) number(s): here 2
mySmsIntent.putExtra("sms_body" , "happy birthday to you");// the message
of course you need sms permissions
and of course you have to addapt the code to fragment (this.getActivity()) if you are using P5 >vs 3
Possible relevant:
Demo code to receive SMS in Android/Processing - Processing Forum
Is access to SMS available? - Processing Forum
Receiving SMS in Processing - Processing 2.x and 3.x Forum
Kf
Thank you, @akenaton! That was neat…
i’m new too processing and android.
how can I enable send or recive sms permission?
@masoud ===
use the android SMS class:
import android.telephony.SmsManager;
String numero= “your phone number”;
String phoneNumberReceiver=numero;// phone number to which SMS to be send
String message=“your message…”;// message to send
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumberReceiver, null, message, null, null);
add sms permissions, either in the manifest or runtime, depending of the target SDK; as for runtime i have already put code for that, using intent && startActivityForResult.