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


Java SmsMessage.isReplace方法代码示例

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


在下文中一共展示了SmsMessage.isReplace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertMessage

import android.telephony.SmsMessage; //导入方法依赖的package包/类
/**
 * If the message is a class-zero message, display it immediately
 * and return null.  Otherwise, store it using the
 * <code>ContentResolver</code> and return the
 * <code>Uri</code> of the thread containing this message
 * so that we can use it for notification.
 */
private Uri insertMessage(Context context, SmsMessage[] msgs, int error, String format) {
    // Build the helper classes to parse the messages.
    SmsMessage sms = msgs[0];

    if (sms.getMessageClass() == SmsMessage.MessageClass.CLASS_0) {
        displayClassZeroMessage(context, sms, format);
        return null;
    } else if (sms.isReplace()) {
        return replaceMessage(context, msgs, error);
    } else {
        return storeMessage(context, msgs, error);
    }
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:21,代码来源:SmsReceiverService.java

示例2: onReceive

import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    Log.i(TAG, "onReceive");
    abortBroadcast();

    mContext = context;
    mPrefs = PreferenceManager.getDefaultSharedPreferences(context);

    if (intent.getExtras() != null) {
        Object[] pdus = (Object[]) intent.getExtras().get("pdus");
        SmsMessage[] messages = new SmsMessage[pdus.length];
        for (int i = 0; i < messages.length; i++) {
            messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
        }

        SmsMessage sms = messages[0];
        if (messages.length == 1 || sms.isReplace()) {
            mBody = sms.getDisplayMessageBody();
        } else {
            StringBuilder bodyText = new StringBuilder();
            for (SmsMessage message : messages) {
                bodyText.append(message.getMessageBody());
            }
            mBody = bodyText.toString();
        }

        mAddress = sms.getDisplayOriginatingAddress();
        mDate = sms.getTimestampMillis();

        if (mPrefs.getBoolean(SettingsFragment.SHOULD_I_ANSWER, false) &&
                PackageUtils.isAppInstalled(mContext, "org.mistergroup.muzutozvednout")) {

            ShouldIAnswerBinder shouldIAnswerBinder = new ShouldIAnswerBinder();
            shouldIAnswerBinder.setCallback(new ShouldIAnswerBinder.Callback() {
                @Override
                public void onNumberRating(String number, int rating) {
                    Log.i(TAG, "onNumberRating " + number + ": " + String.valueOf(rating));
                    shouldIAnswerBinder.unbind(context.getApplicationContext());
                    if (rating != ShouldIAnswerBinder.RATING_NEGATIVE) {
                        insertMessageAndNotify();
                    }
                }

                @Override
                public void onServiceConnected() {
                    try {
                        shouldIAnswerBinder.getNumberRating(mAddress);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onServiceDisconnected() {
                }
            });

            shouldIAnswerBinder.bind(context.getApplicationContext());
        } else {
            insertMessageAndNotify();
        }
    }
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:64,代码来源:MessagingReceiver.java

示例3: SmsMmsMessage

import android.telephony.SmsMessage; //导入方法依赖的package包/类
/**
 * Construct SmsMmsMessage given a raw message (created from pdu), used for
 * when a message is initially received via the network.
 */
public SmsMmsMessage(Context _context, SmsMessage[] messages, long _timestamp) {
    SmsMessage sms = messages[0];

    context = _context;
    timestamp = _timestamp;
    messageType = MESSAGE_TYPE_SMS;

    /*
     * Fetch data from raw SMS
     */
    fromAddress = sms.getDisplayOriginatingAddress();
    fromEmailGateway = sms.isEmail();
    messageClass = sms.getMessageClass();

    String body = "";

    try {
        if (messages.length == 1 || sms.isReplace()) {
            body = sms.getDisplayMessageBody();
        } else {
            StringBuilder bodyText = new StringBuilder();
            for (int i = 0; i < messages.length; i++) {
                bodyText.append(messages[i].getMessageBody());
            }
            body = bodyText.toString();
        }
    } catch (Exception e) {
    }
    messageBody = body;

    /*
     * Lookup the rest of the info from the system db
     */

    SMSUtils.ContactIdentification contactIdentify = null;

    // If this SMS is from an email gateway then lookup contactId by email
    // address
    if (fromEmailGateway) {
        contactIdentify = SMSUtils.getPersonIdFromEmail(context, fromAddress);
        contactName = fromAddress;
    } else { // Else lookup contactId by phone number
        contactIdentify = SMSUtils.getPersonIdFromPhoneNumber(context, fromAddress);
        contactName = PhoneNumberUtils.formatNumber(fromAddress);
    }

    if (contactIdentify != null) {
        contactId = contactIdentify.contactId;
        contactLookupKey = contactIdentify.contactLookup;
        contactName = contactIdentify.contactName;
    }

    unreadCount = SMSUtils.getUnreadMessagesCount(context, timestamp, messageBody);
}
 
开发者ID:RSenApps,项目名称:Commandr-Android,代码行数:59,代码来源:SmsMmsMessage.java

示例4: SmsMmsMessage

import android.telephony.SmsMessage; //导入方法依赖的package包/类
/**
 * Construct SmsMmsMessage given a raw message (created from pdu), used for
 * when a message is initially received via the network.
 */
public SmsMmsMessage(Context _context, SmsMessage[] messages, long _timestamp) {
    SmsMessage sms = messages[0];

    context = _context;
    timestamp = _timestamp;
    messageType = MESSAGE_TYPE_SMS;

    /*
     * Fetch data from raw SMS
     */
    fromAddress = sms.getDisplayOriginatingAddress();
    fromEmailGateway = sms.isEmail();
    messageClass = sms.getMessageClass();

    String body = "";

    try {
        if (messages.length == 1 || sms.isReplace()) {
            body = sms.getDisplayMessageBody();
        } else {
            StringBuilder bodyText = new StringBuilder();
            for (int i = 0; i < messages.length; i++) {
                bodyText.append(messages[i].getMessageBody());
            }
            body = bodyText.toString();
        }
    } catch (Exception e) {
        if (BuildConfig.DEBUG) Log.v("SmsMmsMessage<init> exception: " + e.toString());
    }
    messageBody = body;

    /*
     * Lookup the rest of the info from the system db
     */

    ContactIdentification contactIdentify = null;

    // If this SMS is from an email gateway then lookup contactId by email
    // address
    if (fromEmailGateway) {
        if (BuildConfig.DEBUG) Log.v("Sms came from email gateway");
        contactIdentify = SmsPopupUtils.getPersonIdFromEmail(context, fromAddress);
        contactName = fromAddress;
    } else { // Else lookup contactId by phone number
        if (BuildConfig.DEBUG) Log.v("Sms did NOT come from email gateway");
        contactIdentify = SmsPopupUtils.getPersonIdFromPhoneNumber(context, fromAddress);
        contactName = PhoneNumberUtils.formatNumber(fromAddress);
    }

    if (contactIdentify != null) {
        contactId = contactIdentify.contactId;
        contactLookupKey = contactIdentify.contactLookup;
        contactName = contactIdentify.contactName;
    }

    unreadCount = SmsPopupUtils.getUnreadMessagesCount(context, timestamp, messageBody);
}
 
开发者ID:minhkhoi209,项目名称:EngLishReminder,代码行数:62,代码来源:SmsMmsMessage.java


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