Android
Using the Android sample bundle
The Android example bundle in samples/android
shows how to connect to an
Android device and turn on WLAN.
Prerequisites
You will need a working nodecg-io
installation. If you have non yet take a
look at installation guide. You may need to
install this bundle, so take a look at the
“Try an included sample”-Guide. It
will also tell you how to log in and how to use the GUI.
You also need:
- Clone this Git Repository
- Run
gradlew build
(on Windows) or./gradlew build
(on Linux) inside the cloned repository. - There will be an apk file generated in
app/build/outputs/apk/debug/app-debug.apk
. Install it on the Android device. - Launch the app. You'll be asked to grant the system alert window permission. This is required because the app will do its work in the background. However, occasionally when user interaction is required, it needs to launch an activity without the user pressing the app icon in the launcher.
- Install the android developer tools and make sure you have the
adb
command in yourPATH
- Enable developer options on you device and enable USB debugging there. See here.
- Run
adb start-server
- Connect your device via USB. You'll be prompted whether you want to allow USB
debugging. Press
Allow
. -
Run
adb device -l
. The output might look like this:######## device usb:2-1.7 product:######## model:######## device:######## transport_id:2
The hexadecimal number in the first column is your device ID. You'll need this later.
-
In NodeCG, create a new android service instance.
-
Enter the following:
{ "device": "device_id" }
Replace
device_id
with your device ID.After entering it, click save.
-
Set the sample's (
android
) dependency to be the newly created service instance (of typeandroid
). - You should see that WLAN is now activated on your device.