I want to send SMS programmatically using Android Studio. I found the solution.
Now the issue is - API level 23 or latter Google imply some restriction. And sending SMS is marked as "dangerous" permission. But I am not getting any details about that. And also I found so many solutions, but none of them for newer API. Now my question is - can I send SMS? If yes, what is the solution. Please help me.
Thanks in advance.
What I have tried:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(<PhoneNo>, null, <Text>, null, null);
Added permission SEND_SMS on AndroidManifest.xml:
<uses-permission android:name="android.permission.SEND_SMS" />
And also check permission at runtime:
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.SEND_SMS}, 0);
}