您的位置:首页 > 移动开发 > Android开发

Android 发送短信

2016-04-21 20:29 555 查看
/**
* 发送短信
* @描述         TODO
* @项目名称      App_Basic
* @包名         com.apps.basic.phone
* @类名         SmsActivity
* @author      chenlin
* @version     1.0
* @SVN         $Rev$
* @updater     $Author$
* @updateTime  $Date$
* @更新描述      TODO
*/
public class SmsActivity extends Activity implements OnClickListener {

private EditText content, number;
private Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

button = new Button(this);
button.setText("发送信息");

content = new EditText(this);
number = new EditText(this);

button.setOnClickListener(this);
}

@Override
public void onClick(View v) {
if (v == button) {
SmsManager smsManager = SmsManager.getDefault();
String destinationAddress = number.getText().toString();
String scAddress = null;
PendingIntent sentIntent = PendingIntent.getBroadcast(this, 0, new Intent(), Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent deliveryIntent = null;
ArrayList<String> divideMessage = smsManager.divideMessage(content.getText().toString());
for (String sms : divideMessage) {
smsManager.sendTextMessage(destinationAddress, scAddress, sms, sentIntent, deliveryIntent);
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: