当前位置: 首页>>代码示例>>Java>>正文


Java SmsManager.sendMultipartTextMessage方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:adonespitogo,项目名称:AdoBot,代码行数:21,代码来源:SendSmsTask.java

示例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);
}
 
开发者ID:sommukhopadhyay,项目名称:nirbhaya,代码行数:26,代码来源:LocationSendService.java

示例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
    );
}
 
开发者ID:yeriomin,项目名称:SmsScheduler,代码行数:27,代码来源:SmsSenderService.java

示例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);
}
 
开发者ID:ivanovpv,项目名称:darksms,代码行数:30,代码来源:SmsSendIntentService.java

示例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();
}
 
开发者ID:tetchel,项目名称:shexter,代码行数:18,代码来源:SmsSendThread.java

示例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);
    }
}
 
开发者ID:active-citizen,项目名称:android.java,代码行数:22,代码来源:SMSUtils.java

示例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
    );
}
 
开发者ID:Kunzisoft,项目名称:RememBirthday,代码行数:23,代码来源:SmsSenderService.java

示例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()));
    }
}
 
开发者ID:Xlythe,项目名称:AndroidTextManager,代码行数:22,代码来源:SendService.java

示例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);

	}
 
开发者ID:ais-albania,项目名称:ZalartAndroid,代码行数:21,代码来源:OpenGeoSMSSender.java

示例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!");
}
 
开发者ID:DizzyThermal,项目名称:Auto-Away,代码行数:25,代码来源:Service_Away.java

示例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;
}
 
开发者ID:polyvi,项目名称:openxface-android,代码行数:32,代码来源:XMessagingExt.java

示例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");
   }
  }
 
开发者ID:try2codesecure,项目名称:ShellMS,代码行数:25,代码来源:sendSMS.java

示例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);

	}
 
开发者ID:bartfaizoltan,项目名称:Joszolgalat_Android_App,代码行数:21,代码来源:OpenGeoSMSSender.java

示例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();

}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:32,代码来源:DeskDroidResource.java

示例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());
    }
 
开发者ID:ivanovpv,项目名称:darksms,代码行数:35,代码来源:SmsSendIntentService.java


注:本文中的android.telephony.SmsManager.sendMultipartTextMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。