微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何以编程方式在Android中打开SMS窗口?

如何解决如何以编程方式在Android中打开SMS窗口?

| 在我的应用程序中,我想以编程方式为我的应用程序打开android SMS创建窗口。怎么做?

解决方法

这可能有帮助,也可能没有帮助。
// 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();
        }
    });

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。