How to open SMS window in android programatically?

人盡茶涼 提交于 2021-02-07 19:41:41

问题


In my application i want to open the android SMS creating window for my application programatically. How to do that?


回答1:


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();
        }
    });


来源:https://stackoverflow.com/questions/5710188/how-to-open-sms-window-in-android-programatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!