与Firebase数据库比较时更改变量

时间:2019-01-09 19:31:43

标签: java android broadcastreceiver

我正在两台手机上测试该应用程序。我的电话1正在发送验证码,该验证码是SIM卡的实际IMSI号码,电话2必须从电话1读取SMS。如果Firebase中存储的IMSI号码与电话1的IMSI号码匹配,则会显示一条消息确认确认将被发回。

预期结果:b3方法甚至sendCode中的imsi变量都相同。

onDataChange

下面是我收到消息并将其与Firebase值进行比较的部分:

public void sendCode(View view) {
    final String phoneNumber = ccp.getFullNumberWithPlus();

    SmsManager sms = SmsManager.getDefault();

    List<String> messages = sms.divideMessage("Your IMSI code is: " + imsi);
    Toast.makeText(getApplicationContext(), "Code has been sent to: " + phoneNumber + "." + " You shall be receiving the SMS shortly. ", Toast.LENGTH_LONG).show();
    sendButton.setEnabled(false);

    for (String msg : messages) {
        PendingIntent sentIntent = PendingIntent.getBroadcast(this, 0, new Intent("SMS_SENT"), 0);
        PendingIntent deliveredIntent = PendingIntent.getBroadcast(this, 0, new Intent("SMS_DELIVERED"), 0);
        sms.sendTextMessage(phoneNumber, null, msg, sentIntent, deliveredIntent);
        String id = databasePhone.push().getKey();
        PhoneandVerificationCode phone = new PhoneandVerificationCode(phoneNumber, imsi);
        databasePhone.child(id).setValue(phone, imsi);
        Snackbar sb = Snackbar.make(findViewById(android.R.id.content), "Phone successfully added to the database. ", Snackbar.LENGTH_LONG);
        sb.show();
    }
}

0 个答案:

没有答案