为什么Firebase会在显式更改设备的本地日期时停止同步?

akz*_*rma 11 android firebase firebase-realtime-database firebase-console

当我将手机的本地日期设置更改1个月或更长时间,然后重新启动使用Firebase实时数据库的Android应用程序后,它不会从数据库加载数据并继续加载.为什么会这样?Firebase在获取数据之前是否检查设备的本地时间?

这是onCreate() MainActivityAndroid App

在设置中更改日期(10天或更长时间)然后关闭并重新打开应用程序后,进度条永远不会被隐藏.甚至连onCancelled函数都没有被调用.

    final ProgressBar progressBar = findViewById(R.id.progress_bar);
    final TextView textView = findViewById(R.id.textView);
    progressBar.setVisibility(View.VISIBLE);

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");
    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            String value = dataSnapshot.getValue(String.class);
            textView.setText(value);
            progressBar.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onCancelled(DatabaseError error) {
            progressBar.setVisibility(View.INVISIBLE);
        }
    });`
Run Code Online (Sandbox Code Playgroud)

应用程序级别gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.akzarma.testapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

下面是该项目的Github目录链接,这只是一个示例应用程序,它从firebase实时数据库中获取数据:https://github.com/akzarma/testApp

Jam*_*mes 1

正如评论中提到的,最可能的原因与 SSL 有关。SSL 不能很好地处理不正确的日期,因此它无法安全地连接到 Firebase。解决此问题的一种可能方法是通过 http 连接到 Firebase,但 1) 它不安全 2) 我不确定它是否仍然受支持。