Android Tutorial Android Things - Getting Started

Discussion in 'Tutorials & Examples' started by Erel, Jan 3, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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:
    Code:
    adb connect Android.local
    Check that it is actually connected with
    Code:
    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:
    Code:
    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:
    Code:
    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:
    Code:
    lblMyIp.Text = "My ip: " & Starter.server.GetMyWifiIP
    'To
    lblMyIp.Text = "My ip: " & Starter.server.GetMyIP
     
    Last edited: Jan 3, 2017
    JordiCP, Ohanian, fredo and 12 others like this.
  2. KMatle

    KMatle Expert Licensed User

    Is the RB 2 supported (I can't find any comment that it is not)
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Daniel-White likes this.
  4. miker2069

    miker2069 Active Member Licensed 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!
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    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.

    That's true. As I wrote in the tutorial for a real server you should use B4J with jServer library.

    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: Jan 4, 2017
  6. miker2069

    miker2069 Active Member Licensed User

    Just a point of clarification, would I be able to use the B4A TTS (text to speech) library in an Android Things project?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Just tested it and... it works.

    Code:
    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: Jan 4, 2017
    Peter Simpson and miker2069 like this.
  8. miker2069

    miker2069 Active Member Licensed User

    Sweet! A 1000 times easier than a win universal app on rp3
     
  9. Hypnos

    Hypnos Active Member Licensed 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 likes this.
  10. Erel

    Erel Administrator Staff Member Licensed User

    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).
     
    Hypnos likes this.
  11. iCAB

    iCAB Well-Known Member Licensed 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
     
  12. Erel

    Erel Administrator Staff Member Licensed User

  13. iCAB

    iCAB Well-Known Member Licensed User

    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
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    iCAB likes this.
  15. rtek1000

    rtek1000 Active Member Licensed User

  16. wjzhou

    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 ?
     
  17. alwaysbusy

    alwaysbusy Expert Licensed User

    Just started playing with this. Can one use B4A-bridge to debug? I suppose you would need to install bridge first on the PI, but how do you install an .apk file in Android things anyway?
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    See the Things library: https://www.b4x.com/android/forum/threads/android-things.74823/#content

    I'm not familiar with Brillo.
    Android Things is not open source.

    It is possible but not needed. It uses ADB over wifi. You just need to run adb connection Android.local
     
    walterf25 and alwaysbusy like this.
  19. rtek1000

    rtek1000 Active Member Licensed User

  20. iCAB

    iCAB Well-Known Member Licensed 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?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice