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


Java PhoneNumberUtils.normalizeNumber方法代码示例

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


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

示例1: callNumber

import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
/**
 * Uses an implicit intent to make the phone call.
 * Before calling, checks to see if permission is granted.
 *
 * @param view View that was clicked.
 */
public void callNumber(View view) {
    String normalizedPhoneNumber;
    // Find the editText_main view and assign it to editText.
    EditText editText = (EditText) findViewById(R.id.editText_main);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        Log.d(TAG, "Running version earlier than Lollipop. Can't normalize number.");
        normalizedPhoneNumber = editText.getText().toString();
    } else {
        normalizedPhoneNumber =
                PhoneNumberUtils.normalizeNumber(editText.getText().toString());
    }
    // Use format with "tel:" and phone number to create phoneNumber.
    String phoneNumber = String.format("tel: %s", normalizedPhoneNumber);
    // Log the concatenated phone number for dialing.
    Log.d(TAG, getString(R.string.dial_number) + phoneNumber);
    Toast.makeText(this, getString(R.string.dial_number) + phoneNumber,
            Toast.LENGTH_LONG).show();
    // Create the intent.
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    // Set the data for the intent as the phone number.
    callIntent.setData(Uri.parse(phoneNumber));
    // If package resolves to an app, check for phone permission,
    // and send intent.
    if (callIntent.resolveActivity(getPackageManager()) != null) {
        checkForPhonePermission();
        startActivity(callIntent);
    } else {
        Log.e(TAG, "Can't resolve app for ACTION_CALL Intent.");
    }
}
 
开发者ID:google-developer-training,项目名称:android-fundamentals-phone-sms,代码行数:37,代码来源:MainActivity.java

示例2: dial

import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
static void dial(final Context context, String number) {
    number = PhoneNumberUtils.normalizeNumber(number);

    Log.d(TAG, "Dialing phone number: " + number); //NON-NLS

    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Required for Android below v7
    callIntent.setData(Uri.parse("tel:" + number)); //NON-NLS

    try {
        context.startActivity(callIntent); // Call dial number
    } catch (SecurityException e) {
        Log.e(TAG, e.toString());
    }
}
 
开发者ID:ArcticLabs,项目名称:Opendoor,代码行数:16,代码来源:DoorPhone.java

示例3: User

import android.telephony.PhoneNumberUtils; //导入方法依赖的package包/类
User(String name, String number, String password, boolean active, boolean caseSensitive) {
    this.name = name;
    this.number = PhoneNumberUtils.normalizeNumber(number);
    this.password = password;
    this.active = active;
    this.caseSensitive = caseSensitive;

    System.out.println(this.number);
}
 
开发者ID:ArcticLabs,项目名称:Opendoor,代码行数:10,代码来源:User.java


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