7

Hoi! I'm trying to make an automatic night mode for my phone using "Automate", but I can't find certain app activities. How do I get to know what activities are executed in the foreground at the moment, so I can start it?

2
  • Legit question, but you probably want to edit to make sure it doesn't appear off-topic. (lemme do that for you this time, hope I understood it right) // Unrelated: that "hoi" sounds a lot like Temmie.
    – Andy Yan
    Nov 2, 2017 at 6:00
  • Forgot to add: feel free to edit on top or even perform a rollback if I put it wrong - it's your post after all.
    – Andy Yan
    Nov 2, 2017 at 6:11

2 Answers 2

10

Using apps: Current Activity and some similar apps will display the info in the form of floating texts above the screen content.

Using adb (from your PC): dumpsys window windows | grep -E 'mCurrentFocus', or dumpsys activity top (for full info meant for developers)

1
  • Note: it's adb shell ...
    – Déjà vu
    Aug 22, 2021 at 8:44
3

To add to @AndyYan's answer, you can also use a terminal emulator app, if you don't have a computer but have root privileges. In this case, execute su first. Then, to dump the focused activity, the command is

dumpsys activity activities | grep mFocusedActivity

The command, if e.g. executed from Terminal Emulator, gives the following output:

  mFocusedActivity: ActivityRecord{415c7ae u0 jackpal.androidterm/.Term t96}

The command above, as Andy pointed out, merely shows the Terminal's own activity, though. In order to give yourself enough time to open the app you wish to investigate, though, you need to prepend

sleep <seconds> && 

before the actual dumpsyscommand, replacing <seconds> with the number of seconds you want the shell to wait. An example of complete command, thus, will resemble

sleep 10 && dumpsys activity activities | grep mFocusedActivity

After executing the command, open the app you wish to investigate, and keep it in foreground for the number of seconds you specified. Once the time has elapsed, the shell will report the activity's name.


I'm not affiliated to the abovementioned app.

3
  • @AndyYan Who said they can't? It's just a matter of adding sleep x && before dumpsys (x must be replaced by how many seconds the terminal may wait), so that one can open the app they need to investigate, and let the terminal handle the rest. I'll add this to the answer later.
    – Grimoire
    Nov 2, 2017 at 15:47
  • (facepalm) Obviously I'm no terminal guru...
    – Andy Yan
    Nov 2, 2017 at 15:55
  • @AndyYan Me neither. iBug's the one.
    – Grimoire
    Nov 2, 2017 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .