本文整理汇总了Java中android.telephony.PhoneNumberUtils.compare方法的典型用法代码示例。如果您正苦于以下问题:Java PhoneNumberUtils.compare方法的具体用法?Java PhoneNumberUtils.compare怎么用?Java PhoneNumberUtils.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.PhoneNumberUtils
的用法示例。
在下文中一共展示了PhoneNumberUtils.compare方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadRecipients
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
* For a given address type, extract the recipients from the headers.
*
* @param addressType can be PduHeaders.FROM or PduHeaders.TO
* @param recipients a HashSet that is loaded with the recipients from the FROM or TO headers
* @param addressMap a HashMap of the addresses from the ADDRESS_FIELDS header
* @param excludeMyNumber if true, the number of this phone will be excluded from recipients
*/
private void loadRecipients(int addressType, HashSet<String> recipients,
HashMap<Integer, EncodedStringValue[]> addressMap, boolean excludeMyNumber) {
EncodedStringValue[] array = addressMap.get(addressType);
if (array == null) {
return;
}
// If the TO recipients is only a single address, then we can skip loadRecipients when
// we're excluding our own number because we know that address is our own.
if (excludeMyNumber && array.length == 1) {
return;
}
String myNumber = excludeMyNumber ? mTelephonyManager.getLine1Number() : null;
for (EncodedStringValue v : array) {
if (v != null) {
String number = v.getString();
if ((myNumber == null || !PhoneNumberUtils.compare(number, myNumber)) &&
!recipients.contains(number)) {
// Only add numbers which aren't my own number.
recipients.add(number);
}
}
}
}
示例2: getUserPosition
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
@Nullable
private static ListIterator<User> getUserPosition(Context context, User user) {
ArrayList<User> users = getUsers(context);
if (users != null) {
ListIterator<User> iterator;
iterator = users.listIterator();
while (iterator.hasNext()) {
if (PhoneNumberUtils.compare(iterator.next().number, user.number)) {
return iterator;
}
}
}
return null;
}
示例3: equalNumbers
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
private boolean equalNumbers(String number1, String number2) {
// if (PhoneNumberUtils.isUriNumber(number1) || PhoneNumberUtils.isUriNumber(number2)) {
// return compareSipAddresses(number1, number2);
// } else {
// Optim -- first try to compare very simply
if(number1 != null && number2 != null && number1.equals(number2)) {
return true;
}
return PhoneNumberUtils.compare(number1, number2);
// }
}
示例4: isContactFilter
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
public int isContactFilter(Context context, String number)
{
try
{
contentResolver = context.getContentResolver();
contentUri = DatabaseProvider.CONTACT_FILTER_CONTENT_URI;
Cursor cursor = contentResolver.query(contentUri, null, null, null, CONTACT_FILTER.DEFAULT_SORT_ORDER);
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext())
{
String contactFilterNumber = cursor.getString(cursor.getColumnIndex(CONTACT_FILTER.NUMBER));
int contactFilterRecordable = cursor.getInt(cursor.getColumnIndex(CONTACT_FILTER.RECORDABLE));
boolean isIdenticalNumber = PhoneNumberUtils.compare(number, contactFilterNumber);
if (isIdenticalNumber == true)
{
return contactFilterRecordable;
}
}
return -1;
}
catch (Exception e)
{
Log.w("FiltersManager", "isContactFilter : " + context.getString(R.string.log_preferences_filters_manager_error_is_contact_filter) + " : " + number + " : " + e);
databaseManager.insertLog(context, "" + context.getString(R.string.log_preferences_filters_manager_error_is_contact_filter) + " : " + number, new Date().getTime(), 2, false);
return -1;
}
}
示例5: equals
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
if(!(o instanceof Contact)) {
return false;
}
return PhoneNumberUtils.compare(number, ((Contact) o).number);
}
示例6: removeMessagesFromNumber
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
* Call this after a read command to clear the unread messages for that conversation.
* @param number Number for which to remove unread messages.
*/
public void removeMessagesFromNumber(String number) {
for(Iterator<SmsMessage> it = messages.iterator(); it.hasNext();) {
SmsMessage sms = it.next();
if(PhoneNumberUtils.compare(sms.getOriginatingAddress(), number)) {
it.remove();
}
}
}
示例7: getUserFromNumber
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
@Nullable
static User getUserFromNumber(Context context, String number) {
ArrayList<User> users = getUsers(context);
if (users != null) {
for (User user : users) {
if (PhoneNumberUtils.compare(user.number, number)) {
return user;
}
}
}
return null;
}
示例8: onReceive
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
TelephonyManager tm = (TelephonyManager)context.getSystemService(Service.TELEPHONY_SERVICE);
String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (tm.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK &&
PhoneNumberUtils.compare(Database.getDialNumber(context), phoneNumber)) {
Log.d(TAG, "Door dial number found: " + phoneNumber + ", sleeping..."); //NON-NLS NON-NLS
endCallSleeperThread(context);
}
}
示例9: onReceive
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
try {
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
SmsMessage[] msgs = new SmsMessage[pdus.length];
for (int i = 0; i < msgs.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
String msg_from = msgs[i].getOriginatingAddress();
String msgBody = msgs[i].getMessageBody();
if (!Utils.isBlank(smsInnerData.sender)) {
if (!PhoneNumberUtils.compare(context, msg_from, smsInnerData.sender)) {
continue;
}
}
if (!Utils.isBlank(smsInnerData.content)) {
if (!msgBody.contains(smsInnerData.content)) {
continue;
}
}
changeSatisfiedState(true);
return;
}
changeSatisfiedState(false);
} catch (Exception e) {
Logger.d("Exception caught",e.getMessage());
}
}
}
示例10: isPhoneGranted
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
public boolean isPhoneGranted(String phone) {
for (String grantedPhone : grantedPhones) {
if (PhoneNumberUtils.compare(phone, grantedPhone))
return true;
}
return false;
}
示例11: isSupportNumber
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
public boolean isSupportNumber(String contactNumber) {
return PhoneNumberUtils.compare(getSupportNumber(), contactNumber);
}