Code example for PhoneNumberFormattingTextWatcher

            mTextView = textView;
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
            return new PhoneNumberFormattingTextWatcher(mCountryCode);
        protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
            if (watcher == null || isCancelled()) {
                return; // May happen if we cancel the task. 
            // Setting a text changed listener is safe even after the view is detached. 
            // Note changes the user made before onPostExecute() will not be formatted, but 
            // once they type the next letter we format the entire text, so it's not a big deal. 
            // (And loading PhoneNumberFormattingTextWatcher is usually fast enough.) 
            // We could use watcher.afterTextChanged(mTextView.getEditableText()) to force format 
Experience pair programming with AI  Get Codota for Java