I am trying to position the emulated phone in Android Studio virtual device. Launching the Nexus S API 21 virtual device, places the emulation at the top of top of the screen and I'm unable to get the Windows frame to move the emulation or to minimize the device. So it is fixed at the top.
I have tried to modify the file “emulator-user.ini” for this simulation . I can change the window’s. Y location to lets say 530. When the emulator graphics becomes visible I see it on my monitor at what I assume is the Y 500 location for a quick flash and then it quickly shifts back to the top of the screen where y equals 0 and I am unable to position the device. Is there some way to set the starting location?
You can resize your Android Emulator by connecting to it via telnet:
$ adb devices
List of devices attached
emulator-5560 device
$ telnet localhost 5560
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
window scale 0.75
OK
I found an answer on this website by rephrasing the question in a google search:
Press the Alt-Space keys and you should get the window with the option allowing you to move the emulator window. Then move it e.g. using keyboard arrows. It works for me on Windows 7.
Credit goes to JeriB on April 9
Related
I've been doing development with Flutter. I was using a real hardware but wanted to use an emulator. I set it up but there's this issue.
I usually put my apps in virtual desktops and I switch between them with Ctrl+Meta+[arrow keys]. Each of them have a special purpose, usually desktop 1 is for browsing, desktop 2 is for development and desktop 4 is extra (for testing UI apps and emulator in this case).
However, after I launch Android emulator and switch to a different desktop, it results in the issue seen below:
The red area you see stays unresponsive for other apps such as browser, VSCode etc. (i.e. does not respond to clicks). That area is where the emulator is on Desktop 4. And it also keeps showing multitouch tool.
It's a bit annoying so I wanted to ask if anyone got this issue and if they have any solutions.
Thanks in advance.
Environment
Kubuntu 20.04
AMD Radeon R7 240/340
Solution 1
I have, somehow in a weird way, found a workaround for this issue.
After having this issue, go to the emulator window and press the magnifying glass with a plus button icon twice.
After that, it will drop that weird multitouch state and it won't bother you even as you switch desktop.
Rebooting computer will result in the same bug, however, you have to do it again.
Solution 2
Another method that works is to simply resize the window. If you have a device frame on your emulator, you can simply hold down the Meta key and hold right click and resize your window.
Solution 3
You can also maximize the window. If you have device frame around emulator window, you can press ALT+F3, which opens up window options menu, then click "Maximize". This will get rid of it.
I am having a problem with running Android 7.1 on a virtual machine inside OpenNebula (QEMU/KVM) - more specifically, a problem with mouse integration.
When creating a machine, I tried setting the input two ways:
1. Mouse/USB
2. Tablet/USB
In case 1. the mouse cursor is not in the location it should be (more to the left/right/up/down, depending on speed of mouse movement).
In case2. I have to hold left-click to move the cursor - this makes it move but also works as holding down the finger on touch screen.
My question is: is there a way to set the correct input type, so I can use the mouse normally when working with the system?
Info: It was not a problem in Android 4.4, where the Table/USB option worked correctly.
I'm using Android emulator in Jenkins to run functional tests (Cucumber). Everything works fine if the emulator doesn't contain showcase view at the start.
But if there is a showcase view my tests fail, because application runs behind this view.
I've tried to send keyevents using adb to the emulator before using it:
adb shell input keyevent KEYCODE_MENU;
but it doesn't help. I've tried KEYCODE_MENU, KEYCODE_BACK and other keys, but they don't disable this view.
I guess this property should be available as a system preference in the Android, but I can't find it :(
How can I disable showcase view in emulator? I have access to the emulator using adb.
UPDATE
There's no such flag which can be set in emulator config file or passed to emulator at the start.
And I still don't have a clean solution for this, but few workarounds exist. And that's understandable as showcase view is just a view from Launcher application and logic for that is inside Launcher application.
tricky way, but universal: Prepare custom Android Launcher application with disabled showcase (based on AOSP Launcher) and pre-install (replace default launcher) it on target emulator.
manual way, not universal: gather list of emulators used and coordinates of OK button on those, and send appropriate touch coordinates upon emulator start (as Christopher Orr proposed)
You should be able to send a tap event, for example:
adb shell input tap 700 900
That would tap at approximately the correct x,y pixel coordinate for that button on a Nexus 4.
I've started creating a MonkeyRunner script. This is going ok, but whenever I add a MonkeyDevice::touch command, I have to determine the input coordinates by trial-and-error. Basically I guess at the coordinates I want to touch and see if those coordinates result in the button touch I'm trying to test. That works, but it's a slow process. Is there anyway to determine the coordinates of UI controls, perhaps from the layout XML files?
I found how to do it. Use the Pixel Perfect view within Eclipse to determine the x & y coordinates of the UI element. Here's a quick overview:
1) Eclipse must be running
2) Your Android device must be connected (either the real device via ADB, or the emulator)
3) Run the hierarchy viewer (in /tools)
4) Select "Inspect screenshot"
The Pixel Perfect view will launch automatically. Just place the cross-hairs on the UI element. The x and y coordinates, along with the RGB values, are displayed below.
Here's the URL that got me started: http://developer.android.com/guide/developing/debugging/debugging-ui.html#pixelperfect
This post (monkeyrunner: interacting with views), may give you and idea of how to obtain the View's coordinates using AndroidViewClient.
Most of the Android versions you can enable pointer location in Settings->Developer Options. Once you enable it, it is easy to find out the (x,y) coordinates.
you can also use the HierarchyViewer tool in your AndroidSDK>tools folder to take screenshots of the current screen and examine that image pixel by pixel to get exact coordinates.
For devices older than Android 4.0, see the paragraph following this one. Android 4.0 and later include Settings->Developer options->Pointer location toggle which toggles a transparent ribbon across the top of the device screen with coordinates, velocities and touch-pressure readings including swipe tracks and x/y crosshairs for the current touch location. This is a lot easier than using alternatives such as Monkey Recorder and other means. In Android 4.2 and later, Developer options is hidden from the Settings menu and must be enabled by going to Settings->About tablet and tapping on Build number seven times. One can only presume that Android hid Developer options because of the increasingly user-experience-affecting options it contains and the number of consumer calls/complaints to device makers from people who played with it or whose children played with it.
In older versions which may not include a Pointer location toggle, there is an app on the Play Store (aka Android Market), Developers Tools. See link here: https://play.google.com/store/apps/details?id=com.ggb.development
It will show up with a gear icon and the caption Dev Tools on a device and provide similar functionality which Dev Tools in an AVD (Android Virtual Device) has. That includes Dev Tools ->Development settings>No Pointer Location/Pointer Location radio button toggle. Setting that toggle to Pointer Location provides the exact same functionality built-in with Android 4.0 and later. The same application also has a more limited pointer setting at Dev Tools->Pointer Location which limits pointer location to only a blank screen.
Enjoy!
Create a xyz.py file with below code and connect the device and run it in terminal like monkeyrunner xyz.py, then you will get your device in pc, then u click on any button in the recorder it will give you the coordinates, after that explore it to any file and you can use the coordinates.
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
device = mr.waitForConnection()
recorder.start(device)
I found an adb approach. Use adb shell getevent -l to get a list of events, grep for ABS_MT_POSITION (gets the line with touch events in hex) and finally use awk to get the relevant hex values, strip them of zeros and convert hex to decimal that monkey runner uses. This is all done with the following:
adb shell getevent -l | grep ABS_MT_POSITION --line-buffered | awk '{a = substr($0,54,8); sub(/^0+/, "", a); b = sprintf("0x%s",a); printf("%d\n",strtonum(b))}'
This continuously prints the x and y coordinates in the terminal only when you press on the device.
I want to create a virtual device (nexus one) with wvga800, 800x480 but when I do, I can't see the whole screen on my 13" macbook pro, and I can't scroll down to see the bottom of the screen. How can I see the bottom of my virtual phone screen???
thanks,
You can scale your emulator window, to more closely match the actual device size. This is an option when you run the emulator from the Android SDK and AVD Manager. This is the window you get from running the android command, or from Window|Android SDK and AVD Manager in Eclipse.
Not only will this give you an emulator window closer in size to what the actual device is (so you do not assume people can necessarily click on too-small buttons, etc.), but it will also fit your screen.
This is actually possible from your project as well, no need to start the emulator through the manager:
1) go to Run > Run Configurations... > (Select your application on the left hand side) > (Click the "Target" tab on the right hand side).
2) At the bottom there, you'll see 'Emulator launch parameters'. In the 'additional emulator command line options', add '-scale 0.75' (to make the screen 75% of full size)
Next time you start the emulator it will have scaled properly, hooray!
Ok, I found it, you have to START the emulator from the AVD Manager, after you hit the 'START' button, another window pops up allowing you to set the size of the emulator display.
If you run a project from eclipse, you will not get that screen to set the size of the emulator.
To view full emulator make use of it's full screen mode using alt+enter keys on windows & Linux. But, for mac I'm not sure b'cos i have not checked for it; it has to be same like making your media player window full screen. Please do check for mac & update my post.