Android Things have been deprecated. My motivation behind trying to revive this project was that I wanted to run Android on RaspberryPi with a 3.5" GPIO display that had touch support.
However, due to my limited knowledge of Android development, although I got to get the Gradle build to pass and the Activity to display, the Android service that is supposed to run on the background that uses SPI library which enables touch doesn't work.
This could be because I commented out a lot of code related to maven because I didn't understand how to use it. (Looks like jitpack.io is the way to go).
I got the apk to be exported for demo
service but not touch
service. That could also be an another reason why it didn't work.
Anyway, I found that I can buy 3.5", 4.3" and 5" displays that has touch support with HDMI and USB which will satisfy my need. So, I'm going to leave this code so that maybe someone in the future would still be able to make it work for GPIO displays.
https://medium.com/@dirkvranckaert/android-things-and-touch-display-compatibility-b013a77a8bb8 https://medium.com/@dirkvranckaert/android-things-and-a-waveshare-5-display-289c2ef2fe8c
Q: My display is not working. I can only see the rainbow screen but no Android boot animation. What should I do?
A: This build only supports HDMI displays that report supported resolutions using EDID.
1920x1080 resolution is used by default with this build. You can change value in /boot/resolution.txt to use a different resolution that your display supports.
Removing /boot/resolution.txt will use the preferred resolution of your display
- 3.5"
- https://www.amazon.com/gp/product/B0BWK8Q4KC/
- https://www.amazon.com/DIYmalls-Display-Resistive-Touchscreen-Raspberry/dp/B0BFF163RR
- https://www.amazon.com/Coolwell-Touchscreen-Raspberry-Adjustable-Brightness/dp/B0BV2FRPJ8
- https://www.amazon.com/TUOPUONE-Capacitive-Compatible-Resolution-Adjustable/dp/B0CFDSHZVR/
- https://www.amazon.com/Capacitive-Viewing-Integrated-Raspberry-Computers/dp/B0BJ78JYYN (Maybe)
- 4.3"
- 5"
- https://raspberrytips.com/android-raspberry-pi-4/
- https://gist.github.com/talhashraf/bda3b35e98597e545103
- https://docs.gradle.org/current/samples/sample_building_android_apps.html
- https://github.com/android/app-bundle-samples/blob/main/InstantApps/service/app/src/main/AndroidManifest.xml
Before using the driver you need to make sure you have the Input Device Confguration file (.idc) installed on your Android things device. To do so mount the SD card of your Android Things device and in the root partition under /system/usr/idc/
you should copy the AndroidTouchInputDriver.idc file that is available in the root of this project. If you do not copy that file the driver will work but Android will think that the driver is a physical mouse, which obviously results in totally different behaviour.
If having issues with gradle build
- https://github.com/phamtdat/AndroidSnippets/blob/master/Android12AndroidManifestAddMissingAndroidExported/build.gradle
- https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
You can use the library in two different ways:
-
Using the
TouchScreenDriverApplication
Add anApplication
to your source code and reference it from the AndroidManifest. Then extend your application from theTouchScreenDriverApplication
and override thegetDriverProfile()
method. TheDriverProfile
can be initiated usingWaveshareProfile.getInstance(WaveshareProfile.DIMENSION_800_480);
orKedeiProfile.getInstance(KedeiProfile.DIMENSION_480_320);
. This will make sure the correct driver for your display configuration/dimensions will be loaded. -
Implementing the
TouchScreenDriverManager
yourself If you cannot extend yourApplication
from theTouchScreenDriverApplication
then you can use theTouchScreenDriverManager
to load and unload the driver in theonCreate
andonDestroy
methods of yourApplication
instance. The manager is a singleton class that manages any state for you. Using this method you will also have to impelement a callback that providesDriverProfile
for your screen.
Adding a custom driver is really simple. The hardest part in a custom driver is knowing how to read from your touch input display. Eg: https://github.com/dirkvranckaert/touchinputdisplaydriver/pull/12/files
To implement the driver in the library you should extend the eu.vranckaert.driver.touch.driver.Driver
class or the eu.vranckaert.driver.touch.driver.SpiDriver
class in case your touch input display is SPI compatible. If your touch input display uses the XPT2046 touch controller you can even directly extend the eu.vranckaert.driver.touch.driver.XPT2046Driver
class. It's the driver class that will contain the reading/writing logic for your touch display.
Next you need a eu.vranckaert.driver.touch.profile.DriverProfile
which needs a Vendor
(or Vendor.UNKNOWN
in case your vendor is not yet listed), and a ScreenDimension
specifying the width, height and screen ratio. The Ratio
is an enum with fixed ratio values, or again a Ratio.UNKNOWN
if the ratio is not yet listed.
There's a demo module to test your drivers immediately. The demo contains a splash screen, some default Android controls ideally to test touch inputs (a slider, a switch and buttons) and a 'Touch Debugging' mode, when enabled drives a circle on the touch position that you discover from the display. This way you can almost perfect calibrate the driver against the specific display!