Example usage for android.util Patterns PHONE

List of usage examples for android.util Patterns PHONE

Introduction

In this page you can find the example usage for android.util Patterns PHONE.

Prototype

Pattern PHONE

To view the source code for android.util Patterns PHONE.

Click Source Link

Document

This pattern is intended for searching for things that look like they might be phone numbers in arbitrary text, not for validating whether something is in fact a phone number.

Usage

From source file:Main.java

public static boolean mobileNumberValidation(EditText editText) {
    if (nonEmpty(editText)) {
        String mobileNumber = removeBlankSpace(editText.getText().toString().trim());
        return Patterns.PHONE.matcher(mobileNumber).matches();
    } else {/*  w  ww .jav  a 2  s. c o m*/
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:com.berniesanders.fieldthebern.parsing.FormValidator.java

public static boolean isPhoneValid(CharSequence phone) {
    if (Patterns.PHONE.matcher(phone).matches()) {
        return passesPhoneRequirements(phone.toString());
    } else {/*from w w w. j ava  2s  .c  o m*/
        return false;
    }
}

From source file:id.satusatudua.sigap.ui.RegisterActivity.java

@OnClick(R.id.register)
public void register() {
    String nama = this.nama.getText().toString();
    String email = this.email.getText().toString();
    String phoneNumber = phone.getText().toString();

    if (nama.isEmpty()) {
        this.nama.setError("Mohon masukan nama anda!");
    } else if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
        this.email.setError("Mohon masukan alamat email yang valid!");
    } else if (!Patterns.PHONE.matcher(phoneNumber).matches()) {
        this.phone.setError("Mohon masukan no ponsel yang valid!");
    } else {//from  w  w w. j av a 2  s .  c  o  m
        User user = new User();
        user.setName(nama);
        user.setEmail(email);
        user.setPhoneNumber(phoneNumber);
        user.setMale(laki.isChecked());
        user.setFromApps(true);
        user.setStatus(User.Status.SIAP);
        registerPresenter.register(user);
    }
}