I'm trying to make an intent from fragment but getting an error. I see there are a lot of posts on this subject, but nothing resolves my problem. I already added context and getActivity().
The error I am getting is on RegistrationActivity (Unresolved reference)
. How can I reference it? (android studio hints importing RegistrationActivity to ProfileFragment, but I would say that is not a good way to do it).
Here is the code:
val intent = Intent(this@ProfileFragment.context, RegistrationActivity::class.java).apply {}
getActivity().startActivity(intent)
Thanks.
After your comments I imported RegistrationActivity and now it works. It is good to remember that Fragments don't behave like Activities - in Activity you don't have to import another Activity, and in Fragments you need to do it.