Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 默认SMS编辑器设置为enable false_Android - Fatal编程技术网

Android 默认SMS编辑器设置为enable false

Android 默认SMS编辑器设置为enable false,android,Android,在我的应用程序中,我希望用户发送消息,但消息正文不可编辑。它应该由应用程序构建,用户只能发送和读取该短信。 所以我使用了以下代码: Uri uri = Uri.parse("smsto:9860xxxxxx"); Intent it = new Intent(Intent.ACTION_SENDTO, uri); it.putExtra("sms_body", "The SMS text"); startActivity(it); 如何设置SMS编辑器窗口启用和设置自定义消息

在我的应用程序中,我希望用户发送消息,但消息正文不可编辑。它应该由应用程序构建,用户只能发送和读取该短信。 所以我使用了以下代码:

Uri uri = Uri.parse("smsto:9860xxxxxx");   
Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
it.putExtra("sms_body", "The SMS text");   
startActivity(it);

如何设置SMS编辑器窗口启用和设置自定义消息正文?

使用此代码发送SMS消息:

private void sendSMS(String phoneNumber, String message, final int k){   
    String SENT = "SMS_SENT";
    String DELIVERED = "SMS_DELIVERED";

    Intent sentIntent = new Intent(SENT);
    Intent deliveredUntent = new Intent(DELIVERED);


    PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,sentIntent, 0);        
    PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,deliveredUntent, 0);

    //---when the SMS has been sent---
    sentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            switch (getResultCode()){
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "SMS sent "+k,Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                    Toast.makeText(getBaseContext(), "Generic failure",Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_NO_SERVICE:
                    Toast.makeText(getBaseContext(), "No service",Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_NULL_PDU:
                    Toast.makeText(getBaseContext(), "Null PDU",Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_RADIO_OFF:
                    Toast.makeText(getBaseContext(), "Radio off",Toast.LENGTH_SHORT).show();
                    break;
            }
        }
    };

    //---when the SMS has been delivered---
    deliverReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            switch (getResultCode()){
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "SMS delivered", Toast.LENGTH_SHORT).show();
                    break;
                case Activity.RESULT_CANCELED:
                    Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_SHORT).show();
                    break;                      
            }           
        }
    };  

    try{
        registerReceiver(sentReceiver, new IntentFilter(SENT));
        registerReceiver(deliverReceiver, new IntentFilter(DELIVERED));
    } catch (Exception e) {
        e.printStackTrace();
    }

    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI); 
}

为“SMS编辑器窗口”创建自己的布局如何?