I’m implementing disconnection in ChannelList and Channel like below:
override fun onPause() {
super.onPause()
SendBirdUIKit.disconnect { }
}
override fun onResume() {
super.onResume()
SendBirdUIKit.connect { }
}
It works in ChannelList while it crash the app when disconnecting from a channel. The exception is included like below:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.sendbird.android.User.getUserId()' on a null object reference
at com.sendbird.uikit.utils.ChannelUtils.makeProfileUrlsFromChannel(ChannelUtils.java:115)
at com.sendbird.uikit.utils.ChannelUtils.loadChannelCover(ChannelUtils.java:103)
at com.sendbird.uikit.widgets.ChannelPreview.drawChannel(ChannelPreview.java:102)
What is the best practice to disconnect from a channel? Thanks!
Thanks for the reply. However, we have to restrict the connection due to the limit of peak concurrent users. Is there any workaround to disconnect from a ChannelActivity without crashing the app?
@Yongjun_Choi@Doo_Rim Is there a handler observing user ID once init is succeeded? It seems like the app inevitably crashes no matter where I disconnect from the server.
Thanks for your reply and sorry for the confusion. The goal is simple. We’re required to create a 1-on-1 channel using 2 user IDs. When the conversation is ended, we need to disconnect from the Sendbird server. The provided samples do have sign out process with ChannelListActivity. However, it does not include an entry to ChannelActivity in the HomeActivity.
For instance, we’re creating a channel like the following.
GroupChannel.createChannelWithUserIds(ids, true) { channel , e ->
val intent = ChannelActivity.newIntentFromCustomActivity(context, CustomChannelActivity.class, channel.url)
startActivity(intent)
}
The only problem here is that the channel creation works well while it crash when we call SendBirdUIKit.disconnect after the ChannelActivity is finished. (The crash doesn’t occur when ChannelListActivity is finished - Just like how you sign out in the UIKit samples)