How do I programmatically open an SMS window in Android?

In my application, I want to programmatically open the Android SMS creation window for my application. How?

resolvent:

This may or may not help

// LAUNCH SMS EVENT HANDLER
    final Button buttonLaunchSMS= (Button)findViewById(R.id.ButtonLaunchSMSMessage);
    buttonLaunchSMS.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String outCipherText= editTextSMSCipherText.getText().toString();
            String phoneNumber= editTextPhoneNumber.getText().toString();

            // pre-conditions
            if (outCipherText.length() < 1){
                editTextSMSCipherText.setError("Cipher Text is Empty");
                editTextSMSCipherText.requestFocus();
                return;
            }
            if (outCipherText.length()>MAX_SMS_CHAR){
                editTextSMSCipherText.setError("Error. Message Is Too Large.");
                editTextSMSCipherText.requestFocus();
                return;
            }

            String uri= "smsto:"+phoneNumber;
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
            intent.putExtra("sms_body", outCipherText);
            intent.putExtra("compose_mode", true);
            startActivity(intent);
            finish();
        }
    });

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>