- 在项目中的build.gradle下面加上
compile 'com.lsh.smsverification:smsverification:1.0.0'
- 初始化短信
new SmsAPI().initSDK(getApplicationContext(), appkey, appSecret)
- 发送短信的时候调用:
sendVerifyPhoneNum(mPhoneNumber, new SmsAPI.Send_State() {
@Override
public void sendPhoneResult(int stateCode, String des) {
if (stateCode == SmsAPI.SUCCESS_CODE) {
Log.e(stateCode + "", des);
}
}
});
- 发送验证码调用
sendVerificationCode(mVerCode, new SmsAPI.Verification_State() {
@Override
public void sendVerificationCodeResult(int stateCode, String des) {
if (stateCode == SmsAPI.SUCCESS_CODE) {
Log.e(stateCode + "", des);
Toast.makeText(MainActivity.this, "登录成功", Toast.LENGTH_SHORT).show();
}
}
})
- 最后记得取消调用
@Override
protected void onDestroy() {
super.onDestroy();
mSmsAPI.cancelCall();
}