So basically i am going to use one Fragment in two different activities.Except one method of fragment in which I want to change something.So how do i get the name of activity which is using the Fragment so that I can do things depending upon the name of which activity is current.
in Java
try:
getActivity().getClass().getSimpleName()
getActivity()
method from fragment. If your fragment is not attached to activity getActivity() will return null.in Kotlin
try:
activity?.javaClass?.simpleName
The first Ans is great but it's in java so i translate this in koltin
activity?.javaClass?.simpleName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With