當前位置:名人名言大全網 - 短信平臺 - 如何用eclipse編寫android app實現發短信的功能

如何用eclipse編寫android app實現發短信的功能

大概的寫壹下步驟給妳:

1.在android工程的配置文件裏加上調用系統短信功能的權限:

<uses-permission?android:name="android.permission.SEND_SMS"></uses-permission>

<uses-permission?android:name="android.permission.READ_SMS"></uses-permission>

<uses-permission?android:name="android.permission.RECEIVE_SMS"></uses-permissin>

2、主要代碼片段:

public?class?testSms?extends?Activity?{

...

private?void?send1(String?phone,?String?message){

PendingIntent?pi?=?PendingIntent.getActivity(this,?0,?new?Intent(this,?testSms.class),?0);

SmsManager?sms?=?SmsManager.getDefault();

sms.sendTextMessage(phone,?null,?message,?pi,?null);

}

}

參數:phone:手機號碼

? message:短信內容