本文整理汇总了Java中android.telephony.PhoneNumberUtils.isGlobalPhoneNumber方法的典型用法代码示例。如果您正苦于以下问题:Java PhoneNumberUtils.isGlobalPhoneNumber方法的具体用法?Java PhoneNumberUtils.isGlobalPhoneNumber怎么用?Java PhoneNumberUtils.isGlobalPhoneNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.PhoneNumberUtils
的用法示例。
在下文中一共展示了PhoneNumberUtils.isGlobalPhoneNumber方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCallPhoneTo
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
* 调起系统打电话功能
*/
public void doCallPhoneTo(String phoneNumber) {
if (PhoneNumberUtils.isGlobalPhoneNumber(phoneNumber)) {
if (mayCallPhone()) {
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
startActivity(intent);
}
}
}
示例2: checkAddressCompletionStatus
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
* Checks address completion status in the given profile.
*
* If the country code is not set or invalid, but all fields for the default locale's country
* code are present, then the profile is deemed "complete." AutoflllAddress.toPaymentAddress()
* will use the default locale to fill in a blank country code before sending the address to the
* renderer.
*
* @param profile The autofill profile containing the address information.
* @return int The completion status.
*/
@CompletionStatus
public static int checkAddressCompletionStatus(AutofillProfile profile) {
int invalidFieldsCount = 0;
int completionStatus = COMPLETE;
if (!PhoneNumberUtils.isGlobalPhoneNumber(
PhoneNumberUtils.stripSeparators(profile.getPhoneNumber().toString()))) {
completionStatus = INVALID_PHONE_NUMBER;
invalidFieldsCount++;
}
List<Integer> requiredFields = AutofillProfileBridge.getRequiredAddressFields(
AutofillAddress.getCountryCode(profile));
for (int fieldId : requiredFields) {
if (fieldId == AddressField.RECIPIENT || fieldId == AddressField.COUNTRY) continue;
if (!TextUtils.isEmpty(getProfileField(profile, fieldId))) continue;
completionStatus = INVALID_ADDRESS;
invalidFieldsCount++;
break;
}
if (TextUtils.isEmpty(profile.getFullName())) {
completionStatus = INVALID_RECIPIENT;
invalidFieldsCount++;
}
if (invalidFieldsCount > 1) {
completionStatus = INVALID_MULTIPLE_FIELDS;
}
return completionStatus;
}
示例3: doSendSMSTo
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
* 调起系统发短信功能
*/
public void doSendSMSTo(String phoneNumber, String message) {
if (PhoneNumberUtils.isGlobalPhoneNumber(phoneNumber)) {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phoneNumber));
intent.putExtra("sms_body", message);
startActivity(intent);
}
}
示例4: isValidPhone
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
public static boolean isValidPhone(String target) {
if (target.equals("")) {
return false;
}
else if(target.length()!=10){
return false;
}
else {
return PhoneNumberUtils.isGlobalPhoneNumber(target);
}
}
示例5: doSendSMSTo
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
private void doSendSMSTo(String phoneNumber) {
if (PhoneNumberUtils.isGlobalPhoneNumber(phoneNumber)) {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phoneNumber));
mContext.startActivity(intent);
}
}
示例6: isGlobalPhoneNumber
import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
* Checks if the passed in phone number is valid according to global standards.
*
* @param phoneNumber the phone number to be validated.
* @return true if valid, false otherwise
*/
public static boolean isGlobalPhoneNumber(String phoneNumber) {
return !TextUtils.isEmpty(phoneNumber)
&& PhoneNumberUtils.isGlobalPhoneNumber(phoneNumber);
}