• Android -- 短信


    背景                                                                                          

    image

    主要代码                                                                                     

    发送按钮的监听器:

    phone_number_editText = (EditText) findViewById(R.id.phone_number_editText);
            sms_content_editText = (EditText) findViewById(R.id.sms_content_editText);
            send_sms_button = (Button) findViewById(R.id.send_sms_button);
            
            send_sms_button.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View arg0) {
                String phone_number = phone_number_editText.getText().toString().trim();
                String sms_content = sms_content_editText.getText().toString().trim();
                    if(phone_number.equals("")) {
                       Toast.makeText(MainActivity.this, “No”, Toast.LENGTH_LONG).show();
                    } else {
                        SmsManager smsManager = SmsManager.getDefault();
                        if(sms_content.length() > 70) {
                            List<String> contents = smsManager.divideMessage(sms_content);
                            for(String sms : contents) {
                          smsManager.sendTextMessage(phone_number, null, sms, null, null);
                            }
                        } else {
                   smsManager.sendTextMessage(phone_number, null, sms_content, null, null);
                        }
                        Toast.makeText(MainActivity.this,"OK", Toast.LENGTH_SHORT).show();
                    }
                }     
            });

    权限:

    <uses-permission android:name="android.permission.SEND_SMS">

    我是天王盖地虎的分割线                                                               

    这个因为觉得还是很简单的,就木有源码哈。

    转载请注明出处:http://www.cnblogs.com/yydcdut/p/3735243.html

  • 相关阅读:
    barnes-hut算法 && Fast Multipole Methods算法
    最大独立集问题-maximal independent set problem
    kernighan lin算法
    浅析Struts2中的OGNL和ValueStack
    Python框架之Django学习笔记(十四)
    C++抓网页/获取网页内容
    SpiderMonkey-让你的C++程序支持JavaScript脚本
    关于职位的解释---转CSDN的文章
    优雅的css写法
    linux
  • 原文地址:https://www.cnblogs.com/yydcdut/p/3735243.html
Copyright © 2020-2023  润新知