Search in sources :

Example 1 with RequestMobileCodeCallback

use of com.avos.avoscloud.RequestMobileCodeCallback in project ride-read-android by Ride-Read.

the class RegisterFragment method onSendIdentCode.

//发送验证码
private void onSendIdentCode() {
    EditText registerPhone = (EditText) phoneNumView.findViewById(R.id.register_edt_phone);
    telPhone = registerPhone.getText().toString().trim();
    if (telPhone != null && (!telPhone.isEmpty())) {
        Log.i("手机号码:", telPhone);
        AVOSCloud.requestSMSCodeInBackground(telPhone, "骑阅", "注册", 1, new RequestMobileCodeCallback() {

            @Override
            public void done(AVException e) {
                if (e == null) {
                    new CountDownTimer(60000, 1000) {

                        @Override
                        public void onTick(long millisUntilFinished) {
                            indentfyCodeTv.setText(millisUntilFinished / 1000 + "s后重新发送");
                            indentfyCodeTv.setClickable(false);
                        }

                        @Override
                        public void onFinish() {
                            indentfyCodeTv.setText("发送验证码");
                            indentfyCodeTv.setClickable(true);
                        }
                    }.start();
                } else {
                    Toast.makeText(getActivity(), "验证码发送失败", Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        Toast.makeText(getActivity(), "未填手机号码", Toast.LENGTH_SHORT).show();
    }
}
Also used : EditText(android.widget.EditText) AVException(com.avos.avoscloud.AVException) CountDownTimer(android.os.CountDownTimer) RequestMobileCodeCallback(com.avos.avoscloud.RequestMobileCodeCallback)

Aggregations

CountDownTimer (android.os.CountDownTimer)1 EditText (android.widget.EditText)1 AVException (com.avos.avoscloud.AVException)1 RequestMobileCodeCallback (com.avos.avoscloud.RequestMobileCodeCallback)1