Android Things: Raspberry Pi screen timeout - raspberry-pi3

I'm building app on Raspberry Pi with Android Things and I have 7 inch touch screen, but the screen never turns off.
Is it possible to set timeout like in Android phones? or force it to turn off/on.
If I remove the power line and inserted again the screen, it will not work until I reboot.

There are two system settings that control this process: STAY_ON_WHILE_PLUGGED_IN and SCREEN_OFF_TIMEOUT
The STAY_ON_WHILE_PLUGGED_IN setting is set to BATTERY_PLUGGED_AC by default. You can programmatically change this value in your application code with the Settings API:
Settings.Global.putInt(getContentResolver(),
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
You can also make this change from the command line if it is more convenient:
$ adb shell settings put global stay_on_while_plugged_in 0

The approach below works starting with Android Things Developer Preview 5.0. For older releases it has no effect.
Turn off display:
adb shell settings put global stay_on_while_plugged_in 0
Turn on display:
adb shell settings put global stay_on_while_plugged_in 1
adb shell input keyevent 26
For a programmatic solution see #Devunwired's answer.

Related

Enable macos screen recording from Terminal on macOS 11 Big Sur

I would like to enable screen recording from mac terminal.
From the UI it looks like this:
Enable screen recording from UI
The setting is set to false and I want to enable it from the terminal.
The only related command I found was tccutil reset ScreenCapture [com.WHATEVERBUNDLE.YOURAPPID]
But this resets the screen recording option and I want to enable it.
Is it possible?

How do I make the Android emulator full screen on macOS?

I set up a custom Android emulator virtual device in Android Studio and everything seems to work perfectly, but I am not able to full screen the emulator window. I can resize the window just fine, but there's no option for full screen.
I tried running the emulator from the command line and passing the flags -qemu -full-screen, but it shows:
unknown option: -full-screen
please use -help for a list of valid options
even though it is included in the emulator -qemu -help:
-full-screen start in full screen
It looks like this:
Is there any way to make the Android Emulator full screen on macOS?

Standalone Player command line argument "-adapter" syntax

I need to select the monitor my game is displayed on from the command line for dual monitor systems. If I use the Unity Screen Selector Dialog it gives me the choice of which monitor I want to display the game on when starting the game, and it works fine. When I try loading the game from the command line with the command line argument: "MyGame -adapter 1" or "MyGame -adapter 2" it seems to ignore the argument, and just loads the game on the same monitor every time.
Notes:
I have a dual monitor system, but only one video card (GeForce GT 740).
I am using Unity 5.6.1f1 (64-bit), and Window 10.
Please let me know what I am missing.
This is a known bug and it doesn't seem to be fixed at this time. The -adapter argument does not work with any Direct3D above 9.
Go to File --> Build Settings, select your PC Windows platform then go to Other Settings.
From here, disable the Auto Graphics API for Windows checkbox.
You will be given option to chose which Direct3D to use. Make to remove all other Direct3D version and simply just put Direct3D9 there. The 9th version should until Unity fixes this bug.
If that does not work:
Go to File --> Build Settings, select your PC Windows platform then go to Resolution and Presentation.
Disable "Default Is Full Screen" and "Display Resolution Dialog".
Again, if that fails, use the Display API to do through code. You can find more information about that here. I also suggest that you file for a bug report too.

Rotate through chromium tabs on raspberry pi?

We have several TVs, each with a Raspberry Pi hooked up, so they can be used as information dashboards. The current setup stays on one tab the entire time.
I am trying to set it up so that it will automatically rotate through the chromium tabs every 15 seconds, but am not sure how to approach this.
The Pi's, as far as I know, only have a headless OS with chromium installed, which is started on boot in the xinitrc file.
I know there are some chrome plugins that can do this, but I don't think they can be installed on the command line.
Any advice would be appreciated
You can use xdotool with watch to do this:
# rotate tabs after 30 seconds.
watch -n30 "xdotool search --onlyvisible --class chromium key ctrl+Tab"

Android Wear - Start App voice command not working

I have an app installed on Android Wear Emulator that I can directly run from Start->MyApp. However when I want to start it with voice command i.e. Start MyApp, it keeps waiting for something but does not complete. What could be reason for this?
There is a limitation of the current emulator that it does not support voice actions via the keyboard, even though the text appears on the display. You will need to start the application by clicking on the display, then the red G, and then going to the start menu and picking the app from there. You can also quickly start the application using something like this from your development machine:
adb shell am start -n com.example.android.test/.TestActivity
The watch needs to be connected to a phone (device or emulator) with an internet connection for the voice commands to work.

Resources