<uses-permission android:name="android.permission.SEND_SMS" />
private void sendSMS(String phoneNumber,String message){ if(PhoneNumberUtils.isGlobalPhoneNumber(phoneNumber)){ Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:"+phoneNumber)); intent.putExtra("sms_body", message); startActivity(intent); } }
public void sendSMS(String phoneNumber,String message){ android.telephony.SmsManager smsManager = android.telephony.SmsManager.getDefault(); //拆分短信內容,手機短信長度有限制 List<String> divideContents = smsManager.divideMessage(message); for (String text : divideContents) { smsManager.sendTextMessage(phoneNumber, null, text, sentPI, deliverPI); } }