In android studio when launching my app in the emulator, are there any way in order to show the gamepad or tv remote control in this emulator, in order to test properly my game?
After the emulator load - just click on the 3 dots button at the bottom in the side panel.
Choose "Directional Pad" - and the remote is there.
Try sending key events from command line
adb shell input keyevent
usage: input [text|keyevent]
input text <string>
input keyevent <event_code>
Here you can find more details
ADB Shell Input Events
Related
There is a toolbar for the android emulator in android studio for the user to "click" the volume button to send a volume KeyEvent to the application.
android studio emulator tool bar
Are there other android emulators that can do this?
I have tried BlueStacks already but it will adjust the volume only instead of sending the KeyEvent.
For the application that may overwrite the default behavior of the Keyevent
(in this case, KEYCODE_VOLUME_UP & KEYCODE_VOLUME_DOWN, ACTION_UP & ACTION_DOWN),
how can I trigger those events in other android emulators?
I don't know about other emulators, but if you can use adb with them, you can send keycodes with that
adb shell input keyevent 24 // KEYCODE_VOLUME_UP
There's a list of useful stuff including the keycodes here
I'm trying to emulate input from my android application to make some test.
Well, my Android phone (AREO 8.1.0) is connected to USB and my debugger is enabled.
I use some
adb shell input tap 90 310
adb shell input text "banana"
and my keyboard open as well with "banana" text in the text field (keyboard and apps textfield)
The problem is the next step:
adb shell input keyevent 66 # ENTER input
It won't send this command.
I'm thinking its about my custom keyboard.
I use
to find whats the keyevent I need.
I also use the
keyevent KEYCODE_ENTER
keyevent KEYCODE_TAB
...
the keyevent BACK, SPACE, CLEAR works as well but not the ENTER
*by the way, I tried with and without --longpress
Anyone know what is the problem?
I am working on a application, it contain social share options. Whenever I tap on facebook it will open facebook app in the device with share view.
After that, I want to bring my application to foreground.
I tried pressing back button,
press_back_button()
it is unsuccessful.
Is there any way to bring application to foreground in Calabash-android?
You should be able to do it by sending keypresses and screen touches with ADB
adb shell input keyevent KEYCODE_APP_SWITCH to open the recent apps menu
adb shell input tap 300 300
Will send a tap event on the screen but you'll have to play around with the coordinates to get them in the right place.
EDIT:
I just tried on my phone with the following commands and can reopen the most recent app
adb shell input keyevent KEYCODE_APP_SWITCH
adb shell input tap 300 1700
Before trying these commands on your ruby code see if they work from the terminal (not irb).
The second command uses x and y coordinates that will be different depending on the size of the screen on your phone, 300 1700 works for me but you will need to try some different numbers to make it work for you.
To open the second most recent app, which I think is what you will need, I have to run adb shell input tap 300 700. You will need to play around with this and see what works for you.
FINAL EDIT: I've found a nicer way to do this that's not dependant on screen resolution.
adb shell input keyevent KEYCODE_APP_SWITCH
Then to find your app (you may need to send these multiple times to get it to work)
adb shell input keyevent KEYCODE_DPAD_UP
and/or
adb shell input keyevent KEYCODE_DPAD_DOWN
Then to select
adb shell input keyevent KEYCODE_ENTER
you need to run the system command, e.g.
system("adb shell input keyevent KEYCODE_APP_SWITCH”)
This willl open recent activities.
I have a large set of devices that I want to add google accounts to. The google accounts are already setup so I just want to add these existing accounts to the devices through a command line script.
There are two possible ways (Non-Root):
#1 Develop an app that implements the Account Manager and facilates the login process.
#2 Use a series of ADB commands to pass the input strings and stimulate the touch events.
ADB Command Example:
Start the native add account settings screen
ADB shell am start -a android.settings.ADD_ACCOUNT_SETTINGS \
-n com.android.settings/.accounts.AddAccountSettings
Select the absolute coordinates of the screen where the Google account is located. Each device has different screen sizes, so you have to figure out the exact position of your device. If you have multiple apps with login accounts they will also appear here. E.g., Microsoft Office, Reddit, and WhatsApp.
adb shell input tap X Y
Tips: You can enable the Show taps and Pointer location from
Developer Option. This will give you the precious location of the
touch input.
Set the desired input text
adb shell input text "account#gmail.com"
If you want select a keyboard event, pass the event code from the KeyEvent constants
adb shell input keyevent 66
Here, 66 is the event code of "KEYCODE_ENTER"
Repeat the input/touch process until you successfully login to the system.
Is there a way to get the use ADB to simulate a Recent App key press? I do not see it in the list of assigned keys and I am not able to select it using adb input shell tap despite getting the coordinates from the debugging options.
I am trying to automate a task on my own personal phone (Nexus 5 with soft keys) so any hacky way is fine, assuming there is not a clean way to do this.
The solution is to use the KEYCODE_APP_SWITCH KeyEvent:
adb shell input keyevent KEYCODE_APP_SWITCH
See #SimonMarquis answer below
adb shell input keyevent KEYCODE_APP_SWITCH
(OBSOLETE)
I don't think there is a keycode for it.
However, I am able to open the recent apps menu with adb shell input tap (testing on a Nexus 5 with Lollipop). For example:
adb shell input tap 800 1890
adb shell input keyevent KEYCODE_APP_SWITCH
Still works, you don't even have to put its numeric value (187) into the command.