28

How to keep android emulator always on top in ubuntu 14.04 I am using Android Studio 2.1.1 and emulator version of 25.1.6 It was working before updating Android SDK Tools to 25.1.6.

rss
  • 293
  • 1
  • 3
  • 7

7 Answers7

74

I had the same issue. I solved it like below:

First of all be aware that emulator has two different windows that are attached to each other.

  1. Right Click emulator top bar, and set it as always on top
  2. Right Click emulator icon on the dash, and choose "Emulator" this time use shortcut ALT + SPACE to reveal context menu and again choose always on top.

And that's it!

Note : every time you minimizes emulator window, do steps above again.

sdlins
  • 2,195
  • 1
  • 23
  • 31
code8x
  • 1,780
  • 12
  • 15
54

On active widow emulator, press alt + space, select always on top.

MendelG
  • 14,885
  • 4
  • 25
  • 52
Arif Ikhsanudin
  • 739
  • 6
  • 14
  • 2
    Its the best answer. – Sand Of Vega Jun 01 '20 at 04:48
  • Yeah, and looks like cross-DM one, at least it works in Openbox too. – ARA1307 Apr 19 '21 at 21:41
  • The reason why it's hidden is because in the `...` three dot menu in "Settings" there is "Show window frame around device" disabled, alternatively, you can enable it and then you can see the square(nine dots menu) on the system window which displays the same as the `alt` + `space` :) – jave.web Mar 15 '22 at 08:29
7

Fast way in terminal (toggle always_on_top):

wmctrl -i -r $(wmctrl -l | grep ' Android Emulator - ' | sed -e 's/\s.*$//g') -b toggle,above
wmctrl -i -r $(wmctrl -l | grep ' Emulator$' | sed -e 's/\s.*$//g') -b toggle,above
Andrey Izman
  • 1,807
  • 1
  • 24
  • 27
  • Couldn't toggle with any right-clicking on Linux Mint 20 (possibly just clicking on the wrong stuff), but this solution worked like a charm! I made a function for it in my `.bashrc`. – Sasgorilla May 05 '21 at 13:56
1

I know that this question if for Ubuntu, but anyone who wants another solution, as me on Debian, you could try this:

  • Right click on taskbar over "Android Emulator"
  • More Actions
  • Keep Above Others
pmiranda
  • 7,602
  • 14
  • 72
  • 155
  • That's DM specific, it may work in e.g. in Gnome, but in e.g. Openbox there is no such menu yet. – ARA1307 Apr 19 '21 at 21:39
1

Click on the more option button on the side bar of your emulator. Go into settings. Active the option 'Show window frame around device'. Then right click on the window frame of your emulator. Click on the option 'Always on top'. That's it.

Mave Rich
  • 11
  • 1
0

Its work for Windows

-> follow 2 steps:-

enter image description here

0

Andrey Izman's answer is good, but the "always on top" feature is lost when the emulator is minimized...

Based on his code, I've written a shell script that activates "always on top" whenever the emulator is maximized, and deactivates the feature whenever it's minimized. With minor adaptation, this script can work for any application in Linux.

Here is the code for the script:

#!/bin/bash

# get the window ID of the target window
WINDOW_ID=$(wmctrl -l | grep "Android Emulator - " | awk '{print $1}')

# define the code to execute when the window is maximized
function on_maximize() {
  wmctrl -i -r $(wmctrl -l | grep ' Android Emulator - ' | sed -e 's/\s.*$//g') -b add,above
  wmctrl -i -r $(wmctrl -l | grep ' Emulator$' | sed -e 's/\s.*$//g') -b add,above
}

# define the code to execute when the window is minimized
function on_minimize() {
  wmctrl -i -r $(wmctrl -l | grep ' Android Emulator - ' | sed -e 's/\s.*$//g') -b remove,above
  wmctrl -i -r $(wmctrl -l | grep ' Emulator$' | sed -e 's/\s.*$//g') -b remove,above
}

# set initial window state to "unknown"
WINDOW_STATE="unknown"

# loop forever and check for window events
while true; do
  # wait for the window to be maximized or minimized
  geometry_output=$(xdotool getwindowgeometry $WINDOW_ID 2>&1)

  # check if the window was maximized or minimized
  if [[ "$(xprop -id $WINDOW_ID _NET_WM_STATE | grep '_NET_WM_STATE_HIDDEN')" != "" ]]; then
    if [[ "$WINDOW_STATE" != "minimized" ]]; then
      WINDOW_STATE="minimized"
      on_minimize
    fi
  else
    if [[ "$WINDOW_STATE" != "maximized" ]]; then
      WINDOW_STATE="maximized"
      on_maximize
    fi
  fi

  # discard the output of the xdotool command
  echo "$geometry_output" > /dev/null
done

Now follow these steps:

  1. Make sure wmctrl is installed in your system by trying the wmctrl -l command. For Debian-based systems, you can install it with sudo apt-get install wmctrl.

  2. Save the script as a .sh file in any location, for example ~/scripts/emulator_always_on_top.sh.

  3. Execute it in terminal with ~/scripts/emulator_always_on_top.sh &. The & is important to run it as a daemon (background process).

And voilà!

To turn it off you need to manually kill the process. Look for the emulator_always_on_top.sh process in System Monitor and kill it. Maybe I'll tweak out for an easier way someday...

Kindly accepting comments aiming to improve this approach!

P.S.: Credits for GPT for helping me write this code! Although it took several iterations to achieve success.

Dan Maia
  • 177
  • 2
  • 9