Code example for PhoneNumberFormattingTextWatcher

0
        private final Handler mHandler;
        private static final int MSG_GET_TEXT_WATCHER = 1;
 
        public TextWatcherLoadAsyncTask(String countryCode, TextView textView, Handler handler) {
            mCountryCode = countryCode;
            mTextView = textView;
            mHandler = handler;
        } 
 
        @Override 
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... params) {
            return new PhoneNumberFormattingTextWatcherEx(mCountryCode);
        } 
 
        @Override 
        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. 
            mTextView.addTextChangedListener(watcher);