本文整理汇总了Java中android.telephony.SmsManager.sendMultipartTextMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SmsManager.sendMultipartTextMessage方法的具体用法?Java SmsManager.sendMultipartTextMessage怎么用?Java SmsManager.sendMultipartTextMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.SmsManager
的用法示例。
在下文中一共展示了SmsManager.sendMultipartTextMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendSms
import android.telephony.SmsManager; //导入方法依赖的package包/类
public void sendSms(String phonenumber,String message)
{
SmsManager manager = SmsManager.getDefault();
PendingIntent piSend = PendingIntent.getBroadcast(context, 0, new Intent(SMS_SENT), 0);
PendingIntent piDelivered = PendingIntent.getBroadcast(context, 0, new Intent(SMS_DELIVERED), 0);
int length = message.length();
if(length > MAX_SMS_MESSAGE_LENGTH)
{
ArrayList<String> messagelist = manager.divideMessage(message);
manager.sendMultipartTextMessage(phonenumber, null, messagelist, null, null);
}
else
{
manager.sendTextMessage(phonenumber, null, message, piSend, piDelivered);
}
}
示例2: sendSMS
import android.telephony.SmsManager; //导入方法依赖的package包/类
private void sendSMS(String phoneNumber, String message)/* throws IOException*/
{
String newLine = System.getProperty("line.separator");
String finalSMSString = "";// = message;
SmsManager sms = SmsManager.getDefault();
boolean isGPSEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
boolean isNetworkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if((isNetworkEnabled == true) || (isGPSEnabled == true)){
finalSMSString = "%!" + message +"Please open the Nirbhaya App"+ "@" + lat + "#" + lon ;
//finalSMSString = message + lat + "#" + lon ;
Log.i("SMS Message Latitude:" , Double.toString(lat));
Log.i("SMS Messgae Longitude: ", Double.toString(lon));
}
else{
finalSMSString = message;
}
ArrayList<String> msgStringArray = sms.divideMessage(finalSMSString);
sms.sendMultipartTextMessage(phoneNumber, null, msgStringArray, null, null);
}
示例3: sendSms
import android.telephony.SmsManager; //导入方法依赖的package包/类
private void sendSms(SmsModel sms) {
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();
PendingIntent sentPendingIntent = getPendingIntent(sms.getTimestampCreated(), SmsSentReceiver.class);
PendingIntent deliveredPendingIntent = getPendingIntent(sms.getTimestampCreated(), SmsDeliveredReceiver.class);
SmsManager smsManager = getSmsManager(sms.getSubscriptionId());
ArrayList<String> smsMessage = smsManager.divideMessage(sms.getMessage());
boolean deliveryReports = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext())
.getBoolean(SmsSchedulerPreferenceActivity.PREFERENCE_DELIVERY_REPORTS, false)
;
for (int i = 0; i < smsMessage.size(); i++) {
sentPendingIntents.add(i, sentPendingIntent);
if (deliveryReports) {
deliveredPendingIntents.add(i, deliveredPendingIntent);
}
}
smsManager.sendMultipartTextMessage(
sms.getRecipientNumber(),
null,
smsMessage,
sentPendingIntents,
deliveryReports ? deliveredPendingIntents : null
);
}
示例4: sendRawMessage
import android.telephony.SmsManager; //导入方法依赖的package包/类
/**
* @param context
* @param phoneNumber
* @param body
*/
public static void sendRawMessage(Context context, String phoneNumber, String body, String id)
{
SmsManager sms = SmsManager.getDefault();
ArrayList<String> parts=sms.divideMessage(body);
Intent intentSent=new Intent(Constants.ACTION_SMS_SENT);
intentSent.putExtra(Constants.EXTRA_MESSAGE_ID, id);
PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, intentSent, PendingIntent.FLAG_CANCEL_CURRENT);
Intent intentDelivered=new Intent(Constants.ACTION_SMS_DELIVERED);
intentDelivered.putExtra(Constants.EXTRA_MESSAGE_ID, id);
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, intentDelivered, PendingIntent.FLAG_CANCEL_CURRENT);
ArrayList<PendingIntent> sentPIs = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveredPIs = new ArrayList<PendingIntent>();
for(int i=0; i < parts.size(); i++)
{
sentPIs.add(sentPI);
deliveredPIs.add(deliveredPI);
}
sms.sendMultipartTextMessage(phoneNumber, null, parts, sentPIs, deliveredPIs);
if(Me.DEBUG)
Log.i(TAG, "Send message=" + body);
}
示例5: doInBackground
import android.telephony.SmsManager; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(String... params) {
//Log.d(TAG, "About to send " + params[1] + " to " + params[0]);
SmsManager smsm = SmsManager.getDefault();
ArrayList<String> divided = smsm.divideMessage(params[1]);
Log.d(TAG, "Message divided into " + divided.size() + " parts.");
// could wait for the message to _actually_ be sent using PendingIntents
if(divided.size() > 1) {
smsm.sendMultipartTextMessage(params[0], null, divided, null, null);
}
else {
smsm.sendTextMessage(params[0], null, params[1], null, null);
}
Log.d(TAG, "Messages sent successfully, probably.");
return divided.size();
}
示例6: sendSMS
import android.telephony.SmsManager; //导入方法依赖的package包/类
public static void sendSMS(Context context, String phoneNumber, ArrayList<String> text) {
String stringText = AgTextUtil.listToString(text);
Intent messageIntent = new Intent(DELIVER_RECEIVER_FILTER);
messageIntent.putExtra(SENDING_MESSAGE_KEY, stringText);
messageIntent.putExtra(SENDING_PHONE_NUMBER, phoneNumber);
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, messageIntent, 0);
ArrayList<PendingIntent> list = new ArrayList<>();
list.add(deliveredPI);
context.registerReceiver(deliverReceiver, new IntentFilter(DELIVER_RECEIVER_FILTER));
SmsManager sms = SmsManager.getDefault();
try {
sms.sendMultipartTextMessage(phoneNumber,
null,
text,
new ArrayList<PendingIntent>(),
list);
}catch (Exception e) {
unregisterReceiver(context);
GuiUtils.displayOkMessage(context, String.format(context.getString(R.string.error_send_sms), stringText), null);
}
}
示例7: sendSms
import android.telephony.SmsManager; //导入方法依赖的package包/类
private void sendSms(AutoSms sms, boolean deliveryReports) {
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();
PendingIntent sentPendingIntent = getPendingIntent(sms.getDateCreated().getTime(), SmsSentReceiver.class);
PendingIntent deliveredPendingIntent = getPendingIntent(sms.getDateCreated().getTime(), SmsDeliveredReceiver.class);
SmsManager smsManager = getSmsManager(sms.getSubscriptionId());
ArrayList<String> smsMessage = smsManager.divideMessage(sms.getMessage());
for (int i = 0; i < smsMessage.size(); i++) {
sentPendingIntents.add(i, sentPendingIntent);
if (deliveryReports) {
deliveredPendingIntents.add(i, deliveredPendingIntent);
}
}
smsManager.sendMultipartTextMessage(
sms.getRecipientPhoneNumber(),
null,
smsMessage,
sentPendingIntents,
deliveryReports ? deliveredPendingIntents : null
);
}
示例8: sendSMS
import android.telephony.SmsManager; //导入方法依赖的package包/类
private static void sendSMS(Context context, Text text, Uri uri) {
SmsManager sms = SmsManager.getDefault();
TextManager manager = TextManager.getInstance(context);
Contact contact = manager.getMembers(text).get().iterator().next();
if (contact.equals(Contact.UNKNOWN)) {
return;
}
String address = contact.getNumber();
ArrayList<String> messages = sms.divideMessage(text.getBody());
if (messages.size() > 1) {
// TODO: not sure if this works for everyone
ArrayList<PendingIntent> sendIntent = new ArrayList<>();
ArrayList<PendingIntent> deliveryIntent = new ArrayList<>();
sendIntent.add(newSmsSentPendingIntent(context, uri, text.getId()));
deliveryIntent.add(newSmsDeliveredPendingIntent(context, uri, text.getId()));
sms.sendMultipartTextMessage(address, null, sms.divideMessage(text.getBody()), sendIntent, deliveryIntent);
} else {
sms.sendTextMessage(address, null, text.getBody(), newSmsSentPendingIntent(context, uri, text.getId()), newSmsDeliveredPendingIntent(context, uri, text.getId()));
}
}
示例9: sendReport
import android.telephony.SmsManager; //导入方法依赖的package包/类
public boolean sendReport(String address, String url, ReportEntity report) {
String smsMsg = createReport(url, report);
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> msgs = smsManager.divideMessage(smsMsg);
ArrayList<PendingIntent> pendingIntents = new ArrayList<PendingIntent>();
String action = OpenGeoSMSSender.class.getCanonicalName()
+ UUID.randomUUID().toString();
Intent intent = new Intent(action);
for (int i = 0; i < msgs.size(); i++) {
pendingIntents.add(PendingIntent.getBroadcast(mContext, 0, intent,
0));
}
Receiver r = new Receiver();
mContext.registerReceiver(r, new IntentFilter(action));
smsManager.sendMultipartTextMessage(address, null, msgs,
pendingIntents, null);
return r.waitForResult(pendingIntents);
}
示例10: sendSms
import android.telephony.SmsManager; //导入方法依赖的package包/类
@SuppressLint({ "NewApi", "NewApi", "NewApi" })
private void sendSms()
{
SmsManager manager = SmsManager.getDefault();
wakeLock.acquire();
Log.d(TAG, "Wake Lock Acquired!");
if (getMessageContent(getInformStatus()).length() > 160)
{
ArrayList<String> messagelist = manager.divideMessage(getMessageContent(getInformStatus()));
manager.sendMultipartTextMessage(getReturnAddress(), null, messagelist, null, null);
Log.i(TAG, "Multipart Text Message Sent!");
}
else
{
manager.sendTextMessage(getReturnAddress(), null, getMessageContent(getInformStatus()), sentPI, null);
Log.i(TAG, "Text Message Sent!");
}
wakeLock.release();
Log.d(TAG, "Wake Lock Released!");
}
示例11: sendSMS
import android.telephony.SmsManager; //导入方法依赖的package包/类
/**
* 发送短信
* @param app app应用,包含app的描述信息、状态及UI界面
* @param addr 目的地址
* @param body 消息内容
* @return 返回状态结果
*/
private XExtensionResult sendSMS(XIWebContext webContext, String addr, String body){
String regularExpression = "[+*#\\d]+";
if (!addr.matches(regularExpression)) {
throw new IllegalArgumentException(
"address must be digit,*,# or +");
}
IntentFilter smsSendIntentFilter = new IntentFilter(SMS_SENT);
genSendSMSBroadreceiver();
// 注册发送短信的广播接收器
getContext().registerReceiver(
mSendSMSBroadcastReceiver, smsSendIntentFilter);
SmsManager manager = SmsManager.getDefault();
ArrayList<String> textList = manager.divideMessage(body);
ArrayList<PendingIntent> smsSendPendingIntentList = genSMSPendingIntentList(textList);
manager.sendMultipartTextMessage(addr, null, textList,
smsSendPendingIntentList, null);
XExtensionResult er = new XExtensionResult(Status.NO_RESULT);
er.setKeepCallback(true);
return er;
}
示例12: sendsms
import android.telephony.SmsManager; //导入方法依赖的package包/类
private void sendsms(final String phoneNumber, final String message, final Boolean AddtoSent) {
try {
String SENT = TAG + "_SMS_SENT";
Intent myIntent = new Intent(SENT);
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, myIntent, 0);
SmsManager sms = SmsManager.getDefault();
ArrayList<String> msgparts = sms.divideMessage(message);
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<PendingIntent>();
int msgcount = msgparts.size();
for (int i = 0; i < msgcount; i++) {
sentPendingIntents.add(sentPI);
}
sms.sendMultipartTextMessage(phoneNumber, null, msgparts, sentPendingIntents, null);
if (AddtoSent) {
addMessageToSent(phoneNumber, message);
}
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "undefined Error: SMS sending failed ... please REPORT to ISSUE Tracker");
}
}
示例13: sendReport
import android.telephony.SmsManager; //导入方法依赖的package包/类
public boolean sendReport(String address, String url, ListReportModel report) {
String smsMsg = createReport(url, report);
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> msgs = smsManager.divideMessage(smsMsg);
ArrayList<PendingIntent> pendingIntents = new ArrayList<PendingIntent>();
String action = OpenGeoSMSSender.class.getCanonicalName()
+ UUID.randomUUID().toString();
Intent intent = new Intent(action);
for (int i = 0; i < msgs.size(); i++) {
pendingIntents.add(PendingIntent.getBroadcast(mContext, 0, intent,
0));
}
Receiver r = new Receiver();
mContext.registerReceiver(r, new IntentFilter(action));
smsManager.sendMultipartTextMessage(address, null, msgs,
pendingIntents, null);
return r.waitForResult(pendingIntents);
}
示例14: sendMessage
import android.telephony.SmsManager; //导入方法依赖的package包/类
@POST
@Path("conversations")
@Secure
public Response sendMessage(Message message) throws InterruptedException {
final SmsManager sms = SmsManager.getDefault();
final ArrayList<String> parts = sms.divideMessage(message.getBody());
final CountDownLatch sentLatch = new CountDownLatch(parts.size());
final AtomicInteger statusCode =
new AtomicInteger(Response.Status.CREATED.getStatusCode());
final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getResultCode() != Activity.RESULT_OK) {
statusCode.set(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
sentLatch.countDown();
}
};
deskDroidService.registerReceiver(receiver, new IntentFilter("com.steeplesoft.deskdroid.SMS_SENT"));
ArrayList<PendingIntent> sentPIs = new ArrayList<>();
for (int i = 0; i < parts.size(); i++) {
sentPIs.add(PendingIntent.getBroadcast(deskDroidService.getApplicationContext(), 0,
new Intent("com.steeplesoft.deskdroid.SMS_SENT"), 0));
}
sms.sendMultipartTextMessage(message.getAddress(), null, parts, sentPIs, null);
sentLatch.await(5, TimeUnit.SECONDS);
deskDroidService.unregisterReceiver(receiver);
return Response.status(statusCode.get()).build();
}
示例15: sendMessage
import android.telephony.SmsManager; //导入方法依赖的package包/类
private void sendMessage(Context context, Message message)
{
ArrayList<String> parts;
if(!PhoneNumber.isPhoneNumber(message.getAddress())) {
Log.w(TAG, message.toString() + " - can't be used for SMS");
}
SmsManager sms = SmsManager.getDefault();
message.setSentStatus(Message.STATUS_PENDING);
message.setDeliveredStatus(Message.STATUS_PENDING);
/* if(message.getBody()==null)
message.setBody(this.encodeBytes(message.getBody()));
else
message.setBody(this.encodeString(message.getBody()));*/
parts=sms.divideMessage(message.getBody());
Intent intentSent=new Intent(Constants.ACTION_SMS_SENT);
intentSent.putExtra(Constants.EXTRA_MESSAGE_ID, message.getId());
PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, intentSent, PendingIntent.FLAG_CANCEL_CURRENT);
Intent intentDelivered=new Intent(Constants.ACTION_SMS_DELIVERED);
intentSent.putExtra(Constants.EXTRA_MESSAGE_ID, message.getId());
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, intentDelivered, PendingIntent.FLAG_CANCEL_CURRENT);
ArrayList<PendingIntent> sentPIs = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveredPIs = new ArrayList<PendingIntent>();
for(int i=0; i < parts.size(); i++)
{
sentPIs.add(sentPI);
deliveredPIs.add(deliveredPI);
}
message=Me.getMe().getMessageDAO().save(context, message);
sms.sendMultipartTextMessage(message.getAddress(), null, parts, sentPIs, deliveredPIs);
if(Me.DEBUG)
Log.i(TAG, "Send message=" + message.getBody());
}