I try to automatically send an SMS to a specific number when the user presses a button on the screen.
This is my code:
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms:xxxxxxxxxxx")); smsIntent.putExtra("sms_body", "Hello"); startActivity(smsIntent);
xxxxxxx = phone number
I have the following permissions:
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
When I press the button, it brings me to another screen where I can edit my text and click "Submit". I just want him to do this process automatically without transferring me to another screen. Since I already defined my message, I just want to send it to a specific number.
And also I'm not sure if I put the corrent phone number in the second line of code. Do I have to provide the country code first, or can I just put my mobile number on and it will work?
thanks
Alex source share