zoukankan      html  css  js  c++  java
  • android 发送短信

    所需权限<uses-permission android:name="android.permission.SEND_SMS" />

    public class MessageActivity extends Activity {
    	private EditText number;
    	private EditText content;
    	private Button button;
    	
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            number = (EditText) this.findViewById(R.id.number);
            content =  (EditText) this.findViewById(R.id.content);
            button = (Button) this.findViewById(R.id.button);
            
            button.setOnClickListener(ButtonOnClickListener);
        }
        
        private OnClickListener ButtonOnClickListener = new OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			String numberText = number.getText().toString();
    			String contentText = content.getText().toString();
    			
    			SmsManager sms = SmsManager.getDefault();
    			ArrayList<String> texts = sms.divideMessage(contentText);
    			for(String t : texts){
    				sms.sendTextMessage(numberText, null, t, null, null);
    			}
    			Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG);
    		}
        };
    }
    
  • 相关阅读:
    JavaScript 数组去重
    Javascript数组 reduce() 方法
    Vue事件总线(EventBus)
    前端多媒体-音频
    前端多媒体-视频
    VUE3.0 总结
    el-select地区区号选择
    vue中点击获取相应元素
    Markdown 语法
    Codeforces Round #295 (Div. 2) B. Two Buttons 520B
  • 原文地址:https://www.cnblogs.com/docomo/p/3850600.html
Copyright © 2011-2022 走看看