I have a crash: NullPointerException: Parameter specified as non-null is null on setOnMenuItemClickListener
To avoid this situation, I added .setOnSettingMenuClickListener { _, _, _ -> false } instead of .setOnSettingMenuClickListener(null) , now I can open the settings page.
But when I click on Leave chat only the settings page is finished, the CustomChannelActivity, with the chat that I left, is still present, I would like that both activities will be finished after a leaving action.
Calling leaveChannel() should finish the channel activity. Can you please share the code blob that calls leaveChannel() so that we can check and investigate further.
Meanwhile, if you have any other questions please let us know.
Yes, I checked channelUrl and it’s correct.
I’m trying to call super.leaveChannel() but I have the same result, only CustomChannelSettingsActivity is finished:
Talking about NullPointerException, I can reproduce this issue easily, my code is:
class CustomChannelSettingsActivity : ChannelSettingsActivity() {
private var channelUrl: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
channelUrl = intent.extras?.getString(StringSet.KEY_CHANNEL_URL)
}
override fun createChannelSettingsFragment(channelUrl: String): ChannelSettingsFragment? {
return ChannelSettingsFragment
.Builder(channelUrl)
.setCustomChannelSettingsFragment(CustomChannelSettingsFragment())
.setUseHeader(true)
.setUseHeaderRightButton(false)
.setHeaderLeftButtonListener(null)
.setOnSettingMenuClickListener(null)
.build()
}
}
with the error:
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter listener
at com.healthyvirtuoso.android.presentation.ui.chat.customchannelsettings.CustomChannelSettingsFragment.setOnMenuItemClickListener(Unknown Source:2)
at com.sendbird.uikit.fragments.ChannelSettingsFragment$Builder.build(ChannelSettingsFragment.java:737)
at com.healthyvirtuoso.android.presentation.ui.chat.customchannelsettings.CustomChannelSettingsActivity.createChannelSettingsFragment(CustomChannelSettingsActivity.kt:46)
at com.sendbird.uikit.activities.ChannelSettingsActivity.onCreate(ChannelSettingsActivity.java:59)
at com.healthyvirtuoso.android.presentation.ui.chat.customchannelsettings.CustomChannelSettingsActivity.onCreate(CustomChannelSettingsActivity.kt:23)
I know how to reproduce the issue, I have two type of channels in my app, one of them has GroupChannelParams().setPublic(false).setDistinct(true) and the second one has GroupChannelParams().setPublic(true).setDistinct(false).
The first one works correctly, I can leave a channel and all activities are destroyed, but in the second one I have the issue, like in the screen recorder.
I reproduce that on your custom-sample, in CustomCreateChannelFragment I add the params setPublic(true) and setDistinct(false) false: