當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。