本文整理汇总了Java中android.telephony.SmsMessage.getMessageClass方法的典型用法代码示例。如果您正苦于以下问题:Java SmsMessage.getMessageClass方法的具体用法?Java SmsMessage.getMessageClass怎么用?Java SmsMessage.getMessageClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.SmsMessage
的用法示例。
在下文中一共展示了SmsMessage.getMessageClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isExemption
import android.telephony.SmsMessage; //导入方法依赖的package包/类
private boolean isExemption(SmsMessage message, String messageBody) {
// ignore CLASS0 ("flash") messages
if (message.getMessageClass() == SmsMessage.MessageClass.CLASS_0)
return true;
// ignore OTP messages from Sparebank1 (Norwegian bank)
if (messageBody.startsWith("Sparebank1://otp?")) {
return true;
}
return
message.getOriginatingAddress().length() < 7 &&
(messageBody.toUpperCase().startsWith("//ANDROID:") || // Sprint Visual Voicemail
messageBody.startsWith("//BREW:")); //BREW stands for “Binary Runtime Environment for Wireless"
}
示例2: isExemption
import android.telephony.SmsMessage; //导入方法依赖的package包/类
private boolean isExemption(SmsMessage message, String messageBody) {
// ignore CLASS0 ("flash") messages
if (message.getMessageClass() == SmsMessage.MessageClass.CLASS_0)
return true;
// ignore OTP messages from Sparebank1 (Norwegian bank)
if (messageBody.startsWith("Sparebank1://otp?")) {
return true;
}
return
message.getOriginatingAddress().length() < 7 &&
(messageBody.toUpperCase().startsWith("//ANDROID:") || // Sprint Visual Voicemail
messageBody.startsWith("//BREW:")); //BREW stands for “Binary Runtime Environment for Wireless"
}
示例3: 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);
}
}
示例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) {
}
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);
}
示例5: 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);
}