首页 > 移动平台 > 详细

android 发送短信

时间:2014-07-18 19:28:01      阅读:362      评论:0      收藏:0      [点我收藏+]

所需权限<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);
		}
    };
}

android 发送短信,布布扣,bubuko.com

android 发送短信

原文:http://www.cnblogs.com/docomo/p/3850600.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!