開啟簡訊權限
<uses-permission android:name="android.permission.SEND_SMS"/>
發簡訊的函式如下。
public void sendSMS(String USER_SEND_MESSAGE,String TARGET_PHONE_NUMBER){
SmsManager smsManager = SmsManager.getDefault();
try{
smsManager.sendTextMessage(TARGET_PHONE_NUMBER,
null,
USER_SEND_MESSAGE ,
PendingIntent.getBroadcast(getApplicationContext(), 0,new Intent(), 0),null);
Toast.makeText(this,"Send",Toast.LENGTH_SHORT).show();
}
catch(Exception e){
Toast.makeText(this,"Send Error",Toast.LENGTH_SHORT).show();
}
}
文章標籤
全站熱搜
留言列表