開啟簡訊權限

<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();
	}
}

 

文章標籤
全站熱搜
創作者介紹
創作者 Lung-Yu,Tsai 的頭像
Lung-Yu,Tsai

Lung-Yu,Tsai 的部落格

Lung-Yu,Tsai 發表在 痞客邦 留言(0) 人氣(79)