Android Tutorial Android Things - Getting Started

Android Things is a new project of Google that extends the Android OS to SoC (System on a Chip) boards such as Raspberry Pi and Intel Edison.

https://developer.android.com/things/index.html

To get started you need to install the Android Thing image on the SoC computer.
Instructions for Raspberry Pi 3 are available here: https://developer.android.com/things/hardware/raspberrypi.html

Tip: Use 7zip to unzip the zipped image file. Windows Explorer might fail to extract it due to its size.

The next step is to connect ADB to the remote computer. ADB is the tool used to connect to a device in USB debug mode.
You can find it under <android sdk>\platform-tools.

You can use this command to connect:
B4X:
adb connect Android.local

Check that it is actually connected with
B4X:
adb devices
Once connected you can develop with it like you develop with a regular Android phone.

The platform is a bit slow and it will hard crash if you try to access a feature that is not supported. Check the unfiltered logs for more information.

You can add this code to the manifest editor to make your program the default program that starts after boot:
B4X:
AddActivityText(Main,
  <intent-filter>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.IOT_LAUNCHER"/>
  <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
)

Tips:
- You can uninstall a program with:
B4X:
adb uninstall <package name>
- If there are multiple connected devices then you need to add "-s Android.local:5555" to the adb commands.
- You can also use B4J to target these platforms. The advantage of B4A is that it supports UI applications (the ARM Java package doesn't include the UI package).
The advantage of B4J is that you can use jServer library to implement servers. There are other advantages for using Linux instead of Android for server applications.
- Set the #SupportedOrientations attribute to landscape if the screen orientation is wrong.
- Things library (provides access to the hardware pins): https://www.b4x.com/android/forum/threads/android-things.74823/
- From my experience the Wifi settings mentioned in Google tutorial should be avoided. It caused problems with the reported ip address.

.

Source code: https://www.b4x.com/android/forum/threads/72149/#content
Change this line:
B4X:
lblMyIp.Text = "My ip: " & Starter.server.GetMyWifiIP
'To
lblMyIp.Text = "My ip: " & Starter.server.GetMyIP
 
Last edited:

miker2069

Active Member
Licensed User
Longtime User
So this is very compelling. I'm assuming Android Things is basically in the same category as Windows IoT (Google chose not to go full blown and copy the OS name from Microsoft LOL). Before I get to excited, what *can't* I do. Can I do speech synthesis and recognition on an RPI3 with B4A? I've done this on Windows IoT and and RPi3 but the learning curve was kinda steep imo (although learning Windows RT/Universal App programming was worth it for other professional reasons).

I understand the constraints of embedded devices like RPI3 (i.e. don't treat it like a full blown quad core computer w/ lots of memory and storage) but I assume I should be able to consume web services, create a web server, build simple forms, etc.?

This is VERY VERY nice, imo this put the Android Things/B4A combo slightly ahead of Arduino and B4R (don't get me wrong, that's cool too but to have a bigger platform like RPi3 and Joule is really really nice).

Thank You!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Can I do speech synthesis and recognition on an RPI3 with B4A?
If you can do it with Java then you will be able to do it with B4A. I'm not sure whether these features are supported.

but I assume I should be able to consume web services, create a web server, build simple forms, etc.?
That's true. As I wrote in the tutorial for a real server you should use B4J with jServer library.

imo this put the Android Things/B4A combo slightly ahead of Arduino and B4R
Arduino / ESP8266 are microcontrollers. They are not the same as Raspberry Pi which is a small PC.
Some differences (there are many more):
- Boot time of few milliseconds compared to a boot time of one minute.
- Cost less than 2 USD.
- Low power with the ability to deep sleep.
- Real time and predictable. This is a very important aspect. This is why you can create a software serial port in the small Arduino Uno and cannot do the same thing in the Raspberry Pi.
- No OS, no background processes, no permissions, no unexpected updated.

The microcontrollers are the best option when you want to integrate with other hardware modules. There are many use cases where you will want to use both.
 
Last edited:

miker2069

Active Member
Licensed User
Longtime User
Just a point of clarification, would I be able to use the B4A TTS (text to speech) library in an Android Things project?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Just a point of clarification, would I be able to use the B4A TTS (text to speech) library in an Android Things project?
Just tested it and... it works.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     tts.Initialize("tts")
   End If
End Sub

Sub TTS_Ready (Success As Boolean)
   Log(Success)
   If Success Then
     tts.Speak("this is a test", False)
   End If
End Sub
 
Last edited:

Hypnos

Active Member
Licensed User
Longtime User
Thank you Erel! Just tried to install my B4A smb picture viewer into Android Things (PI3) and it works!

I found 1 little issue:

My app will first check datetime when it started and it will cause some problem when I make my program the default program that starts after boot. I got a wrong time value of 01.01.1970.

I think it's because the pi not got the time value yet before my app started so I have to use a timer to delay it for about 15sec.
Just for a reference.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
My app will first check datetime when it started and it will cause some problem when I make my program the default program that starts after boot. I got a wrong time value of 01.01.1970.

I think it's because the pi not got the time value yet before my app started so I have to use a timer to delay it for about 15sec.
I think that there is a possible solution for this. If you are interested then start a new thread in the questions forum (add [things] to the title).
 

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys
I have few questions with regards to this amazing gift to all of us

1. Does this run a full Android OS, meaning can we run any Android App (more or less) on these boards?
2. Can we run it in a single app mode, and if so what is the best way of doing this?
3. how do we access the IO space?

Thank you very much for this amazing feature, it will make a huge difference
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

iCAB

Well-Known Member
Licensed User
Longtime User
Remember that there is no touch screen

When you say there is no touch screen ... is this a limitation of Android Things, or the actual hardware currently supported.

Thanks again for the fantastic work
 

wjzhou

New Member
Hi , i have a question about Brillo & android things

Brillo source code not continued maintain? android things whether or not open source ?

who knows ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys

Can someone highlight the main advantages of using Android things over B4J and Linux for SoC and vice versa

One thing that caught my attention while reading Erel's first post is this:

"You can also use B4J to target these platforms. The advantage of B4A is that it supports UI applications (the ARM Java package doesn't include the UI package). "

Does this mean with B4J we are unable to develop UI applications for these boards?
 
Top