へ
SmsManager smsMgr = SmsManager.getDefault();
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent("SMS_SENT"), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent("SMS_DELIVERED"), 0);
smsMgr.sendTextMessage(Number, null, "txt", sentPI, deliveredPI);
おかげです。これを行う
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int permissionCheck = ContextCompat.checkSelfPermission(RegisterActivity.this, Manifest.permission.SEND_SM);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(RegisterActivity.this, new String[]{Manifest.permission.SEND_SM}, 1);
} else {
sendSMS();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case 1: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
sendSMS();
} else {
finish();
}
}
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}