Mohammed Gadiwala Mohammed Gadiwala - 9 months ago 34
Android Question

How to get the name of the activity from the fragment?

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.




But be careful when you're using getActivity() method from fragment. If your fragment is not attached to activity getActivity() will return null.