I'm trying to create a pop-up dialog that only displays after the first launch of the app, notifying the user of the app's consent to receive notifications. So I have a dialog like this
class MainActivity : BaseActivity() {
private var agreement = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (!agreement) {
val notifyBottomDialogFragment: BottomNotifyFragment = BottomNotifyFragment {
when (it) {
0 -> agreement = true
1 -> agreement = false
}
}
notifyBottomDialogFragment.show(supportFragmentManager, notifyBottomDialogFragment.tag)
notifyBottomDialogFragment.isCancelable = false
} else {
Log.d("test", "not first")
}
However, if I switch back to the main activity from another activity, the dialog will still be displayed. How can I solve this problem, anyone can help?