【问题标题】:Wrong number format错误的数字格式
【发布时间】:2018-12-18 22:49:18
【问题描述】:

我遇到以下问题:

这是我的验证活动代码:

 public void sendVerificationCode(String mobile){
      CodeBar.setVisibility(View.VISIBLE);
      PhoneAuthProvider.getInstance().verifyPhoneNumber(
              "+55"+mobile,
              60,
              TimeUnit.SECONDS,
              TaskExecutors.MAIN_THREAD,
              mCallBack

这是我在 mainActivity 中的代码:

String mPhone = "+"+55+number;
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
intent.putExtra("mobile", mPhone);
startActivity(intent);
Log.d("clima","hey "+ "+"+55+number);

【问题讨论】:

  • 你能提供Log.d("clima","hey "+ "+"+55+number);的结果吗?

标签: java android validation


【解决方案1】:

由于数字格式是个问题,我认为最好的办法是向 sendVerificationCode 方法添加一个 Log.d 调用。所以它看起来像这样:

public void sendVerificationCode(String mobile){
  Log.d("NumberCheck", "The string mobile is - " + mobile); //This should help you identify what the issue is
  CodeBar.setVisibility(View.VISIBLE);
  PhoneAuthProvider.getInstance().verifyPhoneNumber(
          "+55"+mobile,
          60,
          TimeUnit.SECONDS,
          TaskExecutors.MAIN_THREAD,
          mCallBack

那么您应该能够看到导致问题的原因。

【讨论】:

  • 嘿 N1234,我尝试了许多不同的方法,当我在 sendVerificationCode 上仅键入移动设备(不含引号)时,我的应用程序崩溃了,我看到了 logcat,它说给定的字符串为空或null,并且我在MainActivity上添加了一个Log,(Log.d("clima","number: "+ "+"+55+number);) 在应用程序上写入我的数字后返回的数字的值是正确的,所以它应该工作。你想看完整的代码吗?
  • 代码中的 Log.d 调用在哪里?此外,GianhTran 要求的 Log.d 调用的结果是什么?我认为代码肯定会帮助我们了解发生了什么。
  • 编辑了我的答案以提供进一步的帮助
猜你喜欢
  • 2015-02-21
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 2019-07-29
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
  • 2014-10-12
相关资源
最近更新 更多