I work on a very large project. It has a lot of modules and views - activities and fragments. I need to understand what fragment and what activity are running at the moment. Then I need to move to this class of activity and fragment in the project. Is there any way to find the class name? maybe by logs or smth else?
Asked
Active
Viewed 747 times
1
-
1Check this question - https://stackoverflow.com/questions/9294603/how-do-i-get-the-currently-displayed-fragment?answertab=votes#tab-top – Android Geek Jul 07 '21 at 04:15
3 Answers
4
You can use Android Profiler for this. You will also get a lot of details from this tool. Just hover the mouse over the graph, it will show the fragment currently showing.

Eishon
- 1,274
- 1
- 9
- 17
1
You can try Layout Inspector, a feature of android studio. When the app is running on a device that is connected to Android Studio, you can click on any item to see the view id, you can use these ids to find out which activity/fragment they belong to (through xml file)

Hellious
- 180
- 9
0
Use UserVisibleHint for that:
boolean isVisible;
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
isVisible = isVisibleToUser;
}
When you want to check the visibility of the fragment, simply check it.
if (isVisible) {
//Fragment is visible
} else {
//Fragment is not visible
}

Dev4Life
- 2,328
- 8
- 22