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?
-
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 YanCommented 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 YanCommented Nov 2, 2017 at 6:11
2 Answers
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)
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 dumpsys
command, 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.
-
@AndyYan Who said they can't? It's just a matter of adding
sleep x &&
beforedumpsys
(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.– GrimoireCommented Nov 2, 2017 at 15:47 -
-