我正在尝试从 Android 应用程序发送短信,编写了以下代码,但出现编译错误:“找不到符号变量 SEND_SMS”。我还导入了“android.Manifest.permission”但未解决。请帮我。
案例 R.id.SendSMS:
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.SEND_SMS)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS},
MY_PERMISSIONS_REQUEST_SEND_SMS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is …Run Code Online (Sandbox Code Playgroud) android android-manifest android-permissions android-studio android-6.0-marshmallow
android ×1