gpt4 book ai didi

android - Firebase 实时数据库现在无法正常工作?

转载 作者:行者123 更新时间:2023-11-29 19:07:13 26 4
gpt4 key购买 nike

现在 Firebase RealtimeDatabase“写入”正在运行。

这是 firebase 示例代码。

FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");

myRef.setValue("Hello, World!");

myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
String value = dataSnapshot.getValue(String.class);
Log.d(TAG, "Value is: " + value);
}

@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});

ValueEventListeneronDataChange被调用了,但是在firebase控制台的实时数据库中找不到写入的数据。

此外,以前制作的使用实时数据库的应用程序今天无法正常运行。

这是 Firebase 的错误吗?我现在可以做什么?

PS:这是日志消息。

10-14 18:19:52.730 15916-15916/com.example.star_man.firebaserealtimedatabase V/FA: onActivityCreated
10-14 18:19:52.766 15916-15933/com.example.star_man.firebaserealtimedatabase I/art: Do partial code cache collection, code=61KB, data=47KB
10-14 18:19:52.766 15916-15933/com.example.star_man.firebaserealtimedatabase I/art: After code cache collection, code=61KB, data=47KB
10-14 18:19:52.766 15916-15933/com.example.star_man.firebaserealtimedatabase I/art: Increasing code cache capacity to 256KB
10-14 18:19:55.549 15916-15935/com.example.star_man.firebaserealtimedatabase I/art: Starting a blocking GC Instrumentation
10-14 18:19:56.858 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Using measurement service
10-14 18:19:56.860 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Connecting to remote service
10-14 18:19:56.872 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Activity resumed, time: 5619167420
10-14 18:19:56.876 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: ThreadedRenderer.create() translucent=false
10-14 18:19:56.884 15916-15916/com.example.star_man.firebaserealtimedatabase D/InputTransport: Input channel constructed: fd=80
10-14 18:19:56.886 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: setView = DecorView@304ed89[MainActivity] touchMode=true
10-14 18:19:56.905 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: dispatchAttachedToWindow
10-14 18:19:56.949 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1440,2560] result=0x27 surface={isValid=true 525456977920} surfaceGenerationChanged=true
10-14 18:19:56.951 15916-15982/com.example.star_man.firebaserealtimedatabase D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1440x2560]-format:1
10-14 18:19:56.951 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: mHardwareRenderer.initialize() mSurface={isValid=true 525456977920} hwInitialized=true
10-14 18:19:56.981 15916-15970/com.example.star_man.firebaserealtimedatabase D/FA: Connected to remote service
10-14 18:19:56.981 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Processing queued up service tasks: 1
10-14 18:19:57.033 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
10-14 18:19:57.033 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
10-14 18:19:57.035 15916-15916/com.example.star_man.firebaserealtimedatabase D/ViewRootImpl@b6baf53[MainActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 525456977920}
10-14 18:19:57.038 15916-15916/com.example.star_man.firebaserealtimedatabase V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@eceb89a nm : com.example.star_man.firebaserealtimedatabase ic=null
10-14 18:19:57.038 15916-15916/com.example.star_man.firebaserealtimedatabase I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
10-14 18:19:57.051 15916-15916/com.example.star_man.firebaserealtimedatabase D/InputTransport: Input channel constructed: fd=85
10-14 18:20:01.990 15916-15970/com.example.star_man.firebaserealtimedatabase V/FA: Inactivity, disconnecting from the service

最佳答案

试试放OnCompleteListener,是不是调用了

myRef.setValue("Hello, World!", new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
if (databaseError != null) {
Log.d("saving","Data could not be saved " + databaseError.getMessage());
} else {
Log.d("saving","Data saved successfully.");
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e("saving","Saving failed: " + e.getMessage());
}
});

关于android - Firebase 实时数据库现在无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46742714/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com