if (ActivityCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED) {
try {
Cursor temp = db.rawQuery("Select name from profile;", null);
temp.moveToFirst();
Toast.makeText(TrustedContacts.this, ""+c.getString(2), Toast.LENGTH_SHORT).show();
(SmsManager.getDefault()).sendTextMessage("0"+c.getString(2), null, "Automated SMS by Medical Alert App by " + temp.getString(0), null, null);
Toast.makeText(TrustedContacts.this, "SMS Sent!", Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
Toast.makeText(TrustedContacts.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
} else
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, 1);
Here is the Code for sending SMS through SMS Manager on Permission Granted, but the Permission Dialog Box is not showing up.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
I Have added the Permission in Manifest Files too. Same Scenario for Receive Boot Complete Permission. However, the Call_Phone Permission works Perfectly. Cannot identify the issue. Android Studio TargetAPI 23 and MinAPI is 15.