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
Related
I'm trying to add a custom action to the media session's playback state, so it can show an addition button on Android Auto. The code is indeed simple, the button is added and I can receive its callback, but the problem is the button doesn't have an icon:
The code:
val builder = PlaybackStateCompat.Builder()
builder.addCustomAction(
"ACTION_TEST",
"TEST LABEL",
R.drawable.ic_test // I tried vector drawable, png,... nothing works
)
// ...
mediaSession.setPlaybackState(builder.build())
The result: the added button doesn't have an icon, only shows a ripple effect (the circle in the screenshot) when I click it, otherwise it's invisible.
I found out the root cause. It's because Android Studio auto-optimizes the build process to produce minimal APK that can run on current ADB-connected devices.
In my case, AS included only xhdpi resources in the debug APK, therefore Android Audio HeadUnit couldn't load the drawable. Basically, AS silently changed the Gradle config to somewhat like this:
android {
...
productFlavors {
dev {
resConfigs "xhdpi" // <- root cause
}
...
}
}
I can simply run my app from the terminal to get rid of this problem.
If you have the same problem, just ensure the drawable is available for all screen densities (hdpi, xhdpi,...), and check your APK whether it's packaged with resources in all screen densities.
For me, the problem was resolved when I cleared the data of Android App application on my phone.
Was using it to run DHU emulator on desktop. Somehow its caching went awry.
When creating an avd, starting it for the first time and then trying to close the emulator, the user will be prompted with a dialog reading:
Do you want to save the current state for the next quick boot?
Note: Saving the snapshot may take longer because free RAM is low.
I would like to save this parameter, before starting the emulated device, within its config.ini file.
However I'm not clear on which option it is.
Things I tried:
Adding these lines to the config.ini
fastboot.chosenSnapshotFile=
fastboot.forceChosenSnapshotBoot=no
fastboot.forceColdBoot=no
fastboot.forceFastBoot=yes
Creating an additional file within the config.ini directory of the avd called quickbootChoice.ini that simply reads:
saveOnExit = true
Non of which helped, on every first shutdown of the emulated device this dialog pops up...
Thanks in advance
According to https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android/android-emu/android/skin/qt/tool-window.cpp the popup does not appear if the method returns based on this:
if (saveOnExitChoice == SaveSnapshotOnExit::Always &&
(fc::isEnabled(fc::QuickbootFileBacked) ||
(!savesWereSlow && !hasLowRam))) {
return true;
}
Setting QuickbootFileBacked = on in .android/advancedFeatures.ini fixed it for me. See https://androidstudio.googleblog.com/2018/08/android-emulator-28.html.
You can configure this setting in Android Studio, see this answer for instructions: Android emulator - Don't save state by default
If you are starting the emulator from the command line. Then provide the -no-snapshot-save parameter, to prevent it from saving.
emulator #Nexus_5X_API_23 -no-snapshot-save
reference: https://developer.android.com/studio/run/emulator-commandline
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.
I am writing an Android application to control a Nest thermostat. I was able to connect to it just fine and I can read the correct target temperature (turning the nob on the thermostat updates my TextView).
However, when I try to write the target temperature like this, nothing happens:
String thermostatID = mThermostat.getDeviceId();
mNest.thermostats.setTargetTemperatureF(thermostatID, 70);
I tried setting the HVAC mode first, in case I needed that, but this didn't work either:
String thermostatID = mThermostat.getDeviceId();
mNest.thermostats.setHVACMode(thermostatID, "cool");
mNest.thermostats.setTargetTemperatureF(thermostatID, 70);
The Textview flashes 70 for a brief second, but then shoots back up to 77 which is the target temperature that was set by the actual thermostat. Is this an issue with the SDK code for setTargetTemperatureF, or am I missing something simple here?
The permissions for the Nest thermostat are set on the Nest website. Visit https://developer.nest.com/products and sign in. You will be given a list of your products, all you need to do is select one and scroll down to permissions.
Note that after you change permissions, your mobile (or various platform) application will need to rerun authentication for this change to take place.
Try to modify your code as following, then you can set the target temperature.
mNest.setTargetTemperatureF(thermostatID, 70L, null);
I have to open device dock setting through code. I searched but not got proper solution. In samsung galaxy s-3 it goes through settings->Accessory. I tried following code but didn't work
startActivityForResult(new Intent(Settings.System.getString(getContentResolver(), DOCK_SETTING)), 0);
Correct me if I'm wrong, but I believe the reason this doesn't work, (and why you weren't able to find the appropriate Activity Action in the Android Settings), is because Accessory appears to be provided by Samsung for its Galaxy devices. Therefore, you won't be able to find it in the standard Android SDK (yet?).
I'm currently trying to figure out a workaround, so I'll edit this post if I find a solution.
EDIT: Looks like JoxTraex found a way for you to edit the settings via:
Settings.System.putInt(getContentResolver(), "dock_sounds_enabled", 1);
In addition, if you need to modify these settings when the user has docked their device, you should create a BroadcastReceiver to listen for the ACTION_DOCK_EVENT broadcast.
I was able to achieve this through looking at the settings and configuring the setting programatically:
android.provider.Settings.System.putInt(getContentResolver(), "dock_sounds_enabled", 1);
You need the permission:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
The code above will write to the settings that enables the dock sound settings on the samsung s3. However; instead of just writing it you should tell the user that the setting is disabled and you need it enabled and allow the user to confirm they want to enable it via a dialog.
On another note, I don't think its possible to go directly to the settings->accessory screen because its was a custom settings added by Samsung. This action is not provided in the Android SDK, so it would take a while to derive what is the actual action or even if it exists.
And if you want to confirm it just query it:
String where = "name = 'dock_sounds_enabled'";
Cursor c = getContentResolver().query(android.provider.Settings.System.CONTENT_URI, null, where, null, null);
Update
Steps for how to handle the dialog's response for configuring the dock setting:
Grab the setting.. if it's 0, bring up the dialog to enable it, otherwise continue with your processing
Once the dialog is up and the user confirms they want to enable it:
Confirm: Put a 1 into the dock sounds then close the dialog
Deny: Don't set the dock setting then close dialog