如何解决华为帐户工具包自动电话验证不起作用
我一直在尝试让自动电话验证工作,但它没有填写验证。
public class MySMSbroadcastReceiver extends broadcastReceiver {
@Override public void onReceive(Context context,Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null)
{ Status status = bundle.getParcelable(ReadSmsConstant.EXTRA_STATUS); if (status.getStatusCode() == CommonStatusCodes.TIMEOUT) { // Service has timed out and no SMS message that meets the requirement is read. Service ended. doSomethingWhenTimeOut(); }
else if (status.getStatusCode() == CommonStatusCodes.SUCCESS) {
if (bundle.containsKey(ReadSmsConstant.EXTRA_SMS_MESSAGE)) {
// An SMS message that meets the requirement is read. Service ended. doSomethingWhenGetMessage(bundle.getString(ReadSmsConstant.EXTRA_SMS_MESSAGE)); } } } } }
解决方法
我们还需要一个完成回调来捕捉消息以执行操作:
Task<Void> task = ReadSmsManager.start(MainActivity.this);
task.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
if (task.isSuccessful()) {
// The service is enabled successfully. Continue with the process.
doSomethingWhenTaskSuccess();
}
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。