Android ADB commands to locate Activities

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" >>
chmod a+x 

From now on, every time you need to locate the activity in the source code just type from terminal ./

5 thoughts to “Android ADB commands to locate Activities”

  1. Everything is very olen with a very clear description of the challenges.

    It was truly informative. Your website is very helpful.

    Thank you for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *