How can i keep status 'online' in android

前端 未结 3 1671
我在风中等你
我在风中等你 2020-12-22 01:17

Now i\'m trying to make like a instagram chat program using firebase the problem is i want to show that member login status but android life cycle is problem

Here

3条回答
  •  没有蜡笔的小新
    2020-12-22 01:57

    The problems look like your ChatsActivity is destroyed while Glide is trying to load the image. You can use getApplicationContext() to get the current Context. Try to replace,

    Glide.with(ChatsActivity.this).load(user.getImageurl()).into(image_profile);
    

    with

    Glide.with(getApplicationContext()).load(user.getImageurl()).into(image_profile);
    

    Also, you should use .onDisconnect() method given by firebase to check the presence of the user

    When you establish an onDisconnect() operation, the operation lives on the Firebase Realtime Database server. The server checks security to make sure the user can perform the write event requested, and informs the your app if it is invalid. The server then monitors the connection. If at any point the connection times out, or is actively closed by the Realtime Database client, the server checks security a second time (to make sure the operation is still valid) and then invokes the event.

    You can find out more from this doc

提交回复
热议问题