本文整理汇总了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);
}
}
示例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();
}
}
}
示例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);
}
示例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);
}