本文整理汇总了Java中android.telephony.gsm.SmsManager.sendTextMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SmsManager.sendTextMessage方法的具体用法?Java SmsManager.sendTextMessage怎么用?Java SmsManager.sendTextMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.gsm.SmsManager
的用法示例。
在下文中一共展示了SmsManager.sendTextMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.telephony.gsm.SmsManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (!intent.getAction().equals("org.rapidandroid.intents.SMS_FORWARD")) {
throw new RuntimeException();
}
SmsManager smgr = SmsManager.getDefault();
Bundle extras = intent.getExtras();
if (extras != null) {
Log.d(this.getClass().getName(), "SMS forwarding in progress");
String mesg = extras.getString("msg");
String[] fwdnums = extras.getStringArray("forwardNums");
for (String destinationAddr : fwdnums) {
// String destinationAddr = extras.getString(KEY_DESTINATION_PHONE);
// String mesg = extras.getString(KEY_MESSAGE);
smgr.sendTextMessage(destinationAddr, null, mesg, null, null);
}
Log.d(this.getClass().getName(), "SMS forwarding complete");
}
}
示例2: onReceive
import android.telephony.gsm.SmsManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
SmsManager smgr = SmsManager.getDefault();
Bundle extras = intent.getExtras();
if (extras != null) {
if (extras.containsKey(KEY_DESTINATION_PHONE) && extras.containsKey(KEY_MESSAGE)) {
String destinationAddr = extras.getString(KEY_DESTINATION_PHONE);
String mesg = extras.getString(KEY_MESSAGE);
/** TODO if mesg.length > 160(i think?) chars then this throws exception. would need
* to use the version that sends segmented sms **/
smgr.sendTextMessage(destinationAddr, null, mesg, null, null);
}
}
}
示例3: sendSMS
import android.telephony.gsm.SmsManager; //导入方法依赖的package包/类
public static void sendSMS(String destSMS, String message) {
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(destSMS, null, message, null, null);
}
示例4: sayHello
import android.telephony.gsm.SmsManager; //导入方法依赖的package包/类
public void sayHello(View v) {
String _messageNumber="+447933037883";
String messageText = "";
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(_messageNumber, null, messageText, null, null);
}