import android.telephony.SmsManager; //导入方法依赖的package包/类
private void toSendSMS(Context context, String phoneNumber, String content) {
if (context == null) {
throw new IllegalArgumentException("context can not be null.");
}
PendingIntent sentIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
SmsManager smsManager = SmsManager.getDefault();
if (content.length() >= 70) {
//短信字数大于70,自动分条
List<String> ms = smsManager.divideMessage(content);
for (String str : ms) {
//短信发送
smsManager. sendMultipartTextMessage(phoneNumber, null, str, sentIntent, null);
}
} else {
smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
}
}