我被分配了一个项目,我必须自动从Android SDK发送短信。 有人可以帮我解决这个问题吗?
答案 0 :(得分:4)
请参阅此代码,这可能会对您有所帮助。
//Import this Header Files
import android.telephony.TelephonyManager;
import android.telephony.gsm.SmsManager;
// call this send sms function when clicking a Button..
private void sendSMS(String phoneNumber, String message)
{
Log.v("phoneNumber",phoneNumber);
Log.v("MEssage",message);
PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(this, SendSMS.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, pi, null);
}
答案 1 :(得分:2)
你应该可以在这里找到一些东西:http://www.google.de/search?q=android+send+sms
http://mobiforge.com/developing/story/sms-messaging-android是我的第一个热门,并提供了大量信息。
答案 2 :(得分:2)
private void sendSMS()
{
String phoneNumber = "tel:9732000689";
String message = "Hiii..I have reached to inbox!!!";
System.out.println("***in sendSms****");
PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(this, CopyOfTimerWeb.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, pi, null);
Toast.makeText(getBaseContext(),
"Message has been send to"+phoneNumber,
Toast.LENGTH_SHORT).show();
}