Get Current Focused Window Name using AndroidViewClient - android

I am using AndroidViewClient for testing my android application. I need to access name of current focused window. How can I get it?

It's a bit tricky but can be done. The information about the windows and focus is internally maintained by the Views under some conditions.
You may try something like this (choose any view you have):
...
vc = ViewClient(device, serialno, **kwargs2)
vc.dump(window='-1')
no_id1 = vc.findViewByIdOrRaise("id/no_id/1")
no_id1.useUiAutomator = False # this forces getting windows info
no_id1.getXY() # this gets windows info
print no_id1.windows[no_id1.currentFocus]

Related

Set no-touch option to Chrome OS emulator

Good morning. I need to test my application in Chrome OS, but without the "touch screen"
I used this guide to run a emulation of Chrome OS:
https://www.groovypost.com/howto/chrome-os-android-studio/
Ok, I succeeded to run it, I activated the debugging mode and I activated the adb debugging....finally everything is working and I can run my application on it.
The problem is, I want to test it without touchscreen.
I found the hw.screen property inside
~/.android/avd/<machine-name>.avd/hardware-qemu.ini
that was set to hw.screen = multi-touch.
WOW, exactly what I want, let's change it to no-touch.
Inside ~/Android/Sdk/emulator/lib/hardware-properties.ini you can see
# Touch screen type
name = hw.screen
type = string
enum = touch, multi-touch, no-touch
default = multi-touch
abstract = Touch screen type
description = Defines type of the screen.
so, no-touch is a valid option.
The problem is, even if I change it, every time I restart the emulator, it is set back to multi-touch.
I also tried to change the option directly in ~/Android/Sdk/emulator/lib/hardware-properties.ini, that should contain the default option, but no luck...
Someone can tell me who is overwriting this property each time I start the emulation?
How can I remove the touch screen in the emulation?
Launch the emulator from the command line and use the flag -screen no-touch. This is because the emulator overrides the config in the .ini file. That gives no touch screen but the mouse wasn't usable, at least on Windows.
See the docs for more details

R shiny mobile app: prevent PullToRefresh

Context: I am developing a mobile Shiny app using the shinyMobile package, which is a wrapper for the famous framework7 HTML template.
In my app, the user has to make a selection of attributes on a first tab using multiple dropdown lists, and then, on the other tabs, some output is produced. Each tab requires the user to scroll up and down to access all the content and in this process, very often the 'pull to refresh' feature is triggered.
This is really annoying, because the entire attribute selection and output are lost, and the user has to start over from scratch.
What I tried: based on this SO thread which pointed me to this Google developer page, I tried setting the CSS overscroll-behavior property to contain with: body {overscroll-behavior-y: contain;}. PROBLEM: It does not work for me! (tested on Chrome Android)
Minimal reproducible example:
default app, deployed here
library(shiny);library(shinyMobile)
shiny::shinyApp(
ui = f7Page(
f7Card(
h5('try to pull to refresh. normally it should work.')
)
),
server = function(input, output) {}
)
Supposedly fixed app, deployed here
library(shiny);library(shinyMobile)
shiny::shinyApp(
ui = f7Page(
tags$style(type='text/css', '.body{overscroll-behavior-y: contain;}'),
f7Card(
h5('try to pull to refresh. Normally it should not work.')
)
),
server = function(input, output) {}
)
Hope you guys can reproduce my issue and identify what is amiss!!!
You might want to change your css part to: html,body{overscroll-behavior-y: contain;}, see https://stackoverflow.com/a/42509310/3502164.
Then it works for me on my mobile (android chrome).
Reproducible example:
library(shiny)
library(shinyMobile)
app <- shiny::shinyApp(
ui = f7Page(
tags$style(type='text/css', 'html,body{overscroll-behavior-y: contain;}'),
f7Card(
h5('try to pull to refresh. Normally it should not work.')
)
),
server = function(input, output) {}
)
# use host config to access app from mobiles in the same network
shiny::runApp(appDir = app, host = '0.0.0.0')

JavaFxPorts TextField Issue - Android Keyboard wont function

I developed a simple javafx application to be ported in Android Environment, however I cant type any characters in the TextField. I guess its a bug, how to fix this one?
Th problem on galaxy S5 android 5.0.1 is not present but on galaxy tab 4 android 5.0.2 it doesn't work i type but none is displyed.
Tried with normal textfield. And the problem persist also I have added the properties .
Another strange rhig is that the space where recognizer. And the del button . The text not
THe code by example is very easy
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
TextField tt= new TextField();
tt.setTranslateY(-150);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(tt);
borderpane.setCenter(stackPane);
Scene scene = new Scene(borderpane, width, height);
stage.setScene(scene);
Assuming that CustomTextField is just a custom TextField, this is a known issue, not related to the CustomTextField itself, given that it works in other device.
If you debug it:
./adb logcat -v threadtime
you surely find an exception that explains the issue: a StackOverFlow exception.
On older devices it can be solved adding this: create a java.custom.properties file, and include in it this property:
monocle.stackSize=128000
You may also include this one:
monocle.platform=Android
(it will be soon included by default in the next version)
Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.
Build and deploy the project on your mobile and check again.

Android TextField editable = false property issue

I found an issue on TextField with property
editable = "false"
Notice that, i work on Titanium Studio and the issue concern only Android Platform.
Consider a simple window with 2 textfield, the first one have editable property set to false, the second is editable.
Now, run the app, try to enter the first textfield => you can't because is not editable, so is expected behaviour.
Next enter into the second textField which is editable, the soft keyboard get opened and you can enter some text.
Now, don't close the soft keyboard, and tap on the first textfield (the soft keyboard is still opened), you can now enter some text into the first TextField which is normally not editable !
So, somebody have an idea to solve this behaviour ?
Orating System
Name = Mac OS X
Version = 10.11.3
Architecture = 64bit
# CPUs = 4
Memory = 17179869184
Node.js
Node.js Version = 0.12.7
npm Version = 2.11.3
Titanium CLI
CLI Version = 5.0.6
Titanium SDK
SDK Version = 5.2.0.GA
SDK Path = /Users/Me/#/mobilesdk/osx/5.2.0.GA
Target Platform = android

Is there any way to switch on wifi in monkeyrunner otherthan using the cordinates

Is there any way to switch on wifi in monkeyrunner otherthan using the cordinates.?Can we use WifiManager api from monkeyrunner.
from android.net.wifi import WifiManger
is working after copying android.jar file to tool/lib location.But how to invoke the WifiManger methods inside a android fon using monkeyrunner/monkey..??Somebody please help.
You can switch on the wi-fi by another way. Start the activity of settings and go to the "wireless & network settings" and enable it.
Following code is the start the activity of the settings:
# sets a variable with the package's internal name
package = 'com.android.settings'
# sets a variable with the name of an Activity in the package
activity = 'com.android.settings.Settings'
# sets the name of the component to start
runComponent = package + '/' + activity
setting = 'com.android.settings.Settings'
print("")
print("")
print("Start the Activity...")
# Runs the component
device.startActivity(component=runComponent)
After that by the press event use 'DOWN' and 'ENTER' KeyCode and you can enable the wi-fi...!!!
I looked into this exact issue a few months ago. It did not seem possible to me; at least easily. The best way I could find was to use startActivity to get as close to the wi-fi settings as possible, and then program in D-PAD commands until the correct field was highlighted. You may be able to use this logic to develop a small, purpose build, app that onCreate or onResume toggles wi-fi. In my case, it was not worth the amount of time this would have taken.

Categories

Resources