Get current Activity name by adb shell

Here is the command:

adb shell "dumpsys window windows | grep -E 'mCurrentFocus'"

The output would be:

mCurrentFocus=Window{b6a99d1d0 u0}

My activity name is: LauncherActivity

Difference standard, singleTop, singleInstance, singleTask

standard (default) :- Multiple instances of the activity class can be instantiated and multiple instances can be added to the same task or different tasks. This is the common mode for most of the activities.

singleTop :- The difference from standard is, if an instance of the activity already exists at the top of the current task and the system routes the intent to this activity, no new instance will be created because it will fire off an onNewIntent() method instead of creating a new object.

singleTask:- A new task will always be created and a new instance will be pushed to the task as the root. However, if any activity instance exists in any tasks, the system routes the intent to that activity instance through the onNewIntent() method call. In this mode, activity instances can be pushed to the same task. This mode is useful for activities that act as the entry points.

singleInstance:- Same as singleTask, except that the no activities instance can be pushed into the same task of the singleInstance’s. Accordingly, the activity with launch mode is always in a single activity instance task. This is a very specialized mode and should only be used in applications that are implemented entirely as one activity.


To translate for my language:

We have 3 activities A>B>C and we are now in C

  1. standard  – creates everytime new activity. There is nothing to explain.
  2. singleTop – when we are in C and we want startActivity A it will create another A, but when we startActivity C it won’t create it because C is on top
  3. singleTask – when we are in C and we want startActivity A, it will bring to front A, but when we startActivity C it won’t create it because C is the current task
  4. singleInstance – imho don’t know 😀 above explanation might help a bit