Send SMS using android

Asked

Viewed 677 times

0

I have an app and I would like him to send a text to his own mobile but I’m not getting, not from the error just not send.

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("987654321", null, "Texto SMS", null, null);

This is the stretch I have, what to do?

1 answer

1


To send an SMS programmatically on Android is necessary to add the use of permission in the manifest <uses-permission android:name="android.permission.SEND_SMS" />. If you are developing for version 6.0 or higher, you need to make use of Runtime Permission Requests.

After making sure you have permission to send the messages, check the number you are sending. Use the country code (+55), DDD and mobile number containing all digits.

  • I had already added the permission in the manifest, I am using version 4.3. And the number is like this +55 81 987654321. and still not sending.

  • Is there any logcat information? If possible, try to include in the question an excerpt containing possible app/system records. Adding log calls before and after upload test help delimit logs.

  • Solved, I tested in a version higher than 6 and had to put the permission request.

  • Great! Don’t forget to mark the question as solved :)

  • how to mark as resolved?

  • In the upper left corner of the frame with my answer there is a dial (check). When you click it, it will turn green and the answer will be marked as a solution to the question.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.