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


Java SmsManager.divideMessage方法代码示例

本文整理汇总了Java中android.telephony.SmsManager.divideMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SmsManager.divideMessage方法的具体用法?Java SmsManager.divideMessage怎么用?Java SmsManager.divideMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.SmsManager的用法示例。


在下文中一共展示了SmsManager.divideMessage方法的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: sendSmsSilent

import android.telephony.SmsManager; //导入方法依赖的package包/类
/**
 * 发送短信
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SEND_SMS"/>}</p>
 *
 * @param phoneNumber 接收号码
 * @param content     短信内容
 */
public static void sendSmsSilent(String phoneNumber, String content) {
    if (StringUtils.isEmpty(content)) return;
    PendingIntent sentIntent = PendingIntent.getBroadcast(Utils.getContext(), 0, new Intent(), 0);
    SmsManager smsManager = SmsManager.getDefault();
    if (content.length() >= 70) {
        List<String> ms = smsManager.divideMessage(content);
        for (String str : ms) {
            smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
        }
    } else {
        smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
    }
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:21,代码来源:PhoneUtils.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: toSendSMS

import android.telephony.SmsManager; //导入方法依赖的package包/类
/**
 * 发送短信息
 *
 * @param phoneNumber 接收号码
 * @param content     短信内容
 */
private void toSendSMS(Context context, String phoneNumber, String content) {
    if (context == null) {
        throw new IllegalArgumentException("context can not be null.");
    }
    PendingIntent sentIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
    SmsManager smsManager = SmsManager.getDefault();

    if (content.length() >= 70) {
        //短信字数大于70,自动分条
        List<String> ms = smsManager.divideMessage(content);
        for (String str : ms) {
            //短信发送
            smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
        }
    } else {
        smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
    }
}
 
开发者ID:smuyyh,项目名称:SprintNBA,代码行数:25,代码来源:Utils.java

示例8: 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

示例9: 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

示例10: sendSms

import android.telephony.SmsManager; //导入方法依赖的package包/类
@Override
public int sendSms(String address, String smsContent) {
    if (TextUtils.isEmpty(address)) {
        return -1;
    }
    setSmsState(SMS_STATE_SENDING);
    SmsManager smsManager = SmsManager.getDefault();
    List<String> divideContents = smsManager.divideMessage(smsContent);
    Intent sentIntent = new Intent(SENT_SMS_ACTION);
    mContext.registerReceiver(mSmsReceiver, new IntentFilter(SENT_SMS_ACTION));
    PendingIntent pandingIntent = PendingIntent.getBroadcast(mContext, 0, sentIntent, 0);
    for (String text : divideContents) {
        smsManager.sendTextMessage(address, null, text, pandingIntent, null);
    }
    ContentValues values = new ContentValues();
    values.put("date", System.currentTimeMillis());
    values.put("type", 2);
    values.put("address", address);
    values.put("body", smsContent);
    Uri uri = mContext.getContentResolver().insert(Uri.parse("content://sms/sent"), values);
    Log.d(Log.TAG, "uri = " + uri);
    return 0;
}
 
开发者ID:taugin,项目名称:cim,代码行数:24,代码来源:SmsImpl.java

示例11: sendSMS

import android.telephony.SmsManager; //导入方法依赖的package包/类
private void sendSMS(String phoneNumber, String message) {
	// ---sends an SMS message to another device---
	SmsManager sms = SmsManager.getDefault();

	// create the sentIntent parameter
	Intent sentIntent = new Intent(SENT_SMS_ACTION);
	PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, sentIntent,
			0);

	// create the deilverIntent parameter
	Intent deliverIntent = new Intent(DELIVERED_SMS_ACTION);
	PendingIntent deliverPI = PendingIntent.getBroadcast(this, 0,
			deliverIntent, 0);

	// ����������ݳ���70���ַ� ���������Ų�ɶ������ŷ��ͳ�ȥ
	if (message.length() > 70) {
		ArrayList<String> msgs = sms.divideMessage(message);
		for (String msg : msgs) {
			sms.sendTextMessage(phoneNumber, null, msg, sentPI, deliverPI);
		}
	} else {
		sms.sendTextMessage(phoneNumber, null, message, sentPI, deliverPI);
	}
}
 
开发者ID:blueandhack,项目名称:SendSmsN,代码行数:25,代码来源:MainActivity.java

示例12: 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

示例13: 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

示例14: 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

示例15: sendMessage

import android.telephony.SmsManager; //导入方法依赖的package包/类
public static void sendMessage(Context context, MessageItem item) {
    // 这种方法不能在系统短信中查到,需要手动向Provider里写
    SmsManager sms = SmsManager.getDefault();

    if (item.getBody().length() > 70) {
        ArrayList<String> msgs = sms.divideMessage(item.getBody());
        for (String msg : msgs) {
            sms.sendTextMessage(item.getAddress(), null, msg, null, null);
        }
    } else {
        sms.sendTextMessage(item.getAddress(), null, item.getBody(), null,
                null);
    }

    // 将短信数据写入系统短信数据库
    ContentValues values = new ContentValues();
    values.put("date", System.currentTimeMillis());
    values.put("read", 0);
    values.put("type", 2);
    values.put("address", item.getAddress());
    values.put("body", item.getBody());
    context.getContentResolver().insert(Uri.parse("content://sms"), values);
}
 
开发者ID:owwlo,项目名称:Courier.Android,代码行数:24,代码来源:Utils.java


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