There’s always need for communication, right 😉 Suppose we have that has several . Each has a telling that the onboarding flow has finished, and only the last shows this button. OnboardingActivity OnboardingFragment Fragment startButton Fragment Here are several ways you can do that. Any feedback or improvement suggestions are more than welcome. EventBus Nearly all articles I found propose this , but I personally don’t like this idea because components are loosely coupled, every component and broadcast can listen to event from a singleton, which makes it very hard to reason when the project scales greenrobot/EventBus data class OnboardingFinishEvent() class OnboardingActivity: AppCompatActivity() {override fun onStart() {super.onStart() EventBus.getDefault().register(this) } override fun onStop() { EventBus.getDefault().unregister(this) super.onStop() } @Subscribe(threadMode = ThreadMode.MAIN) fun onOnboardingFinishEvent(event: OnboardingFinishEvent) { // finish } } class OnboardingFragment: Fragment() {override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState) startButton.onClick { EventBus.getDefault().post(OnboardingFinishEvent()) } } } Read more about this approach https://gunhansancar.com/ease-communication-between-activities-fragments-services/ Otto Otto from said to be an enhanced Guava-based event bus with emphasis on Android support. However it is deprecated square/otto This project is deprecated in favor of RxJava and RxAndroid. These projects permit the same event-driven programming model as Otto, but they’re more capable and offer better control of threading. RxJava We can use simple to create our own PublishSubject RxBus import io.reactivex.Observableimport io.reactivex.subjects.PublishSubject // Use object so we have a singleton instanceobject RxBus { private val publisher = PublishSubject.create<Any>() fun publish(event: Any) { publisher.onNext(event) } // Listen should return an Observable and not the publisher // Using ofType we filter only events that match that class type fun <T> listen(eventType: Class<T>): Observable<T> = publisher.ofType(eventType) } // OnboardingFragment.ktstartButton.onClick {RxBus.publish(OnboardingFinishEvent())} // OnboardingActivity.ktoverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState) RxBus.listen(OnboardingFinishEvent::class.java).subscribe({ // finish }) } Interface This is advised here . Basically you define an interface that whoever conforms to that, can be informed by the of events. This is similar to pattern in iOS 😉 Communicating with Other Fragments OnboardingFragmentDelegate Fragment Delegate interface OnboardingFragmentDelegate {fun onboardingFragmentDidClickStartButton(fragment: OnboardingFragment)} class OnboardingFragment: Fragment() {var delegate: OnboardingFragmentDelegate? = null override fun onAttach(context: Context?) { super.onAttach(context) if (context is OnboardingFragmentDelegate) { delegate = context } } override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) startButton.onClick { delegate?.onboardingFragmentDidClickStartButton(this) } } } class OnboardingActivity: AppCompatActivity(), OnboardingFragmentDelegate {override fun onboardingFragmentDidClickStartButton(fragment: OnboardingFragment) {onboardingService.hasShown = truestartActivity<LoginActivity>()}} ViewModel We can learn from to to communication between Fragment and Activity, by using a shared that is scoped to the activity. This is a bit overkill Share data between fragments ViewModel class OnboardingSharedViewModel: ViewModel() {val finish = MutableLiveData<Unit>()} class OnboardingActivity: AppCompatActivity(), OnboardingFragmentDelegate {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)val viewModel = ViewModelProviders.of(this).get(OnboardingSharedViewModel::class.java) viewModel.finish.observe(this, Observer { startActivity<LoginActivity>() }) } } Note that we need to call to get the same with the ViewModelProviders.of(activity) ViewModel activity class OnboardingFragment: Fragment() {override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState) val viewModel = ViewModelProviders.of(activity).get(OnboardingSharedViewModel::class.java) startButton.onClick({ viewModel.finish.value = Unit }) } } Lambda Create a lambda in , then set it on . It does not work for now as there is no in 😢 Fragment onAttachFragment OnboardingFragment onAttachFragment class OnboardingFragment: Fragment() {var didClickStartButton: (() -> Unit)? = null override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) startButton.onClick { didClickStartButton?.invoke() } } } class OnboardingActivity: AppCompatActivity() {override fun onAttachFragment(fragment: Fragment?) {super.onAttachFragment(fragment) (fragment as? OnboardingFragment).let { it?.didClickStartButton = { // finish } } } } Listener in Bundle Another proposed way is through listener in bundle, the below post gives more insight into this approach _Activities have their lifecycle, and the same goes forFragments. Hence, communication from Fragments to Activities is…_medium.com From Fragments to Activity: the Lambda Way Original story https://github.com/onmyway133/blog/issues/108 While you are here, you may like my other posts Next to first, next to nothing 20 recommended utility apps for macOS in 2018 Getting to know some pragmatic programming language features How to make tag selection view in React Native If you like this post, consider visiting and 🔥 my other articles apps