Sometimes during debug or bug fixing I need to locate the activities in the source code.
The Android Debug Bridge provides some commands to help us.
Make sure your device is USB connected and the activity to locate is in foreground.
From terminal:
adb shell dumpsys activity activities | grep mFocusedActivity
It will print out something like this:
mFocusedActivity: ActivityRecord{44ff17b u0 com.youpackagename/.ActivityName t14533}
It’s so simple!
I realized I used it so often I created a script.
echo "adb shell dumpsys activity activities | grep mFocusedActivity" >> locator.sh chmod a+x locator.sh
From now on, every time you need to locate the activity in the source code just type from terminal ./locator.sh