1

I have used this code to send SMS

String phoneNumber="000000000000";
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:" + phoneNumber));
intent.putExtra("address", phoneNumber);
intent.putExtra("sms_body", smsContent);
startActivityForResult(intent,RESULT_CODE);

this will send SMS properly

But i had an issue on onActivityResult() ,the result code is always getting 0 , I don't know how to solve this issue,and How will i know that the SMS has been sent or not ?

then tried with SmsSendObserver.SmsSendListener interface to receive the callback.but it is giving an error

java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/ from pid=29471, uid=10277 requires android.permission.READ_SMS, or grantUriPermission()

and i can't give READ_SMS permission due to the google play permission policy update ,so how can i grant URI permission

Milad Bahmanabadi
  • 946
  • 11
  • 27
  • You need to register your app with broadcast and need to listen actions of sms. For this a lot of answers already avaialble – Abdul Waheed Dec 05 '18 at 06:21
  • Possible duplicate of [How to registrate BroadcastReceiver for sms catcher?](https://stackoverflow.com/questions/10664757/how-to-registrate-broadcastreceiver-for-sms-catcher) – Karan Harsh Wardhan Dec 05 '18 at 07:14
  • "how can i grant URI permission" – You can't. That is something that the owner of the data would have to do. Considering Google's new restrictions, I believe your only options are to ensure that the user is using some SMS app that can relay that info to you somehow – which is likely completely infeasible – or to use an alternate method of sending, by which I mean, for example, Twilio, or some other such service. – Mike M. Dec 05 '18 at 14:33
  • I saw a lot of posts about android.provider.Telephony.SMS_RECEIVED but it's only for SMS receiving. i need to know how to detect SMS sending from the phone? – Sadrisya Lohid Dec 06 '18 at 07:39
  • 1
    @MikeM. thank u for ur suggestion ,I'll try with Twilio. – Sadrisya Lohid Dec 06 '18 at 08:03

0 Answers0