Android 短信发送

来源:互联网 发布:js tochararray 编辑:程序博客网 时间:2024/06/06 00:45

关键代码:

SmsManager manager = SmsManager.getDefault();ArrayList<String> texts = manager.divideMessage(content);for(String text : texts){//发送信息,参数1、发送号码,2,中心号码(移动、联通等)   参数3、发送内容,参数4,发送状态 ,参数5,对方是否收到状态manager.sendTextMessage(number, null, text, null, null);}//信息发送完成提示 参数1、上下文对象(getApplicateContext这个对象也是一样)2、发送成功提示的信息3、提示的时间长短Toast.makeText(MainActivity.this, R.string.success, Toast.LENGTH_LONG).show();


 

AndroidMainfest.xml中应加入:

<!-- 申请使用发送短信权限 -->

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