Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DevFest NYC - Ok Google, Build an Android Thing...

DevFest NYC - Ok Google, Build an Android Things Product

Rebecca covered the basics of Android Things, and how you can integrate with the Google Assistant.

Rebecca Franks

December 02, 2017
Tweet

More Decks by Rebecca Franks

Other Decks in Programming

Transcript

  1. Ok Google, Make an Android Things Product Rebecca Franks Android

    Engineering Lead at DVT Google Developer Expert Android @riggaroo
  2. Interactive Ads Vending Machines Point of Sale Stock Control Retail

    Cameras Gateways Access Control Smart Meters Business Asset Tracking Fleet Management Driver Assist Predictive Service Logistics Security Systems Smart Doorbells Routers Energy Monitors Home Android Things is ideal for powerful, intelligent devices that need to be secure.
  3. Applications Launcher Phone Messaging Contacts Calendar Browser Settings Application Framework

    Activity Manager Window Manager Power Manager Resource Manager XMPP Service Content Providers Wallpapers System UI Package Manager Telephony Manager Location Manager Connectivity Manager View System Runtime Permissions Soft Keyboards Notifications Libraries Surface Manager Media Framework Chromium SSL HAL Audio Manager SQLite Open GL libc Core Libraries Android Runtime (ART) Android Runtime Linux Kernel Display Driver Camera Driver Bluetooth Driver Binder (IPC) Driver USB Driver Audio Driver WiFi Driver Power Management
  4. Applications Launcher Phone Messaging Contacts Calendar Browser Settings Application Framework

    Activity Manager Window Manager Power Manager Resource Manager XMPP Service Content Providers Wallpapers System UI Package Manager Telephony Manager Location Manager Connectivity Manager View System Runtime Permissions Soft Keyboards Notifications Libraries Surface Manager Media Framework Chromium SSL HAL Audio Manager SQLite Open GL libc Core Libraries Android Runtime (ART) Android Runtime Linux Kernel Display Driver Camera Driver Bluetooth Driver Binder (IPC) Driver USB Driver Audio Driver WiFi Driver Power Management
  5. Applications Launcher Phone Messaging Contacts Calendar Browser Settings Application Framework

    Activity Manager Window Manager Power Manager Resource Manager XMPP Service Wallpapers System UI Package Manager Telephony Manager Location Manager Connectivity Manager View System Soft Keyboards Notifications Libraries Surface Manager Media Framework Chromium SSL HAL Audio Manager SQLite Open GL libc Core Libraries Android Runtime (ART) Android Runtime Linux Kernel Display Driver Camera Driver Bluetooth Driver Binder (IPC) Driver USB Driver Audio Driver WiFi Driver Power Management Things Support Library Peripheral I/O Device Management User Drivers Connectivity
  6. Distribution with Android Things Android Framework Hardware Libraries Linux Kernel

    Managed by Google Apps User Drivers Managed by Developers
  7. Android Things Console • Manage your Android Things IoT Product

    • Download and install the latest Android Things system image • Build factory images that contain OEM applications along with the system image • Push over-the-air (OTA) updates partner.android.com/things/console
  8. Hardware Integration Peripheral Driver Library - Github + many more...

    bit.ly/androidthings-github Button GPS PWM Servo RGB LED Strip Temperature Sensor Capacitive Touch Buttons Peripheral I/O - Low Level Access GPIO PWM I2C SPI UART I2S
  9. //Automatically added in AndroidManifest.xml <application ...> <uses-library android:name="com.google.android.things"/> <activity ...>

    <!-- Launch activity automatically on boot --> <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> </activity> </application>
  10. //Automatically added in AndroidManifest.xml <application ...> <uses-library android:name="com.google.android.things"/> <activity ...>

    <!-- Launch activity automatically on boot --> <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> </activity> </application>
  11. GPIO - General Purpose Input / Output - Programmable way

    to read true / false values (1 or 0) (push button, PIR Sensor) - Write true/false values (LED) - Configurable
  12. //Accessing Sensor Data private val motionSensorGpio: Gpio = PeripheralManagerService().openGpio(motionSensorPin) fun

    start() { motionSensorGpio.setDirection(Gpio.DIRECTION_IN) motionSensorGpio.setActiveType(Gpio.ACTIVE_HIGH) motionSensorGpio.setEdgeTriggerType(Gpio.EDGE_BOTH) motionSensorGpio.registerGpioCallback(object : GpioCallback() { override fun onGpioEdge(gpio: Gpio): Boolean { if (gpio.value) { motionListener.onMotionDetected() } else { motionListener.onMotionStopped() } return true } }) }
  13. //Accessing Sensor Data private val motionSensorGpio: Gpio = PeripheralManagerService().openGpio(motionSensorPin) fun

    start() { motionSensorGpio.setDirection(Gpio.DIRECTION_IN) motionSensorGpio.setActiveType(Gpio.ACTIVE_HIGH) motionSensorGpio.setEdgeTriggerType(Gpio.EDGE_BOTH) motionSensorGpio.registerGpioCallback(object : GpioCallback() { override fun onGpioEdge(gpio: Gpio): Boolean { if (gpio.value) { motionListener.onMotionDetected() } else { motionListener.onMotionStopped() } return true } }) }
  14. //Accessing Sensor Data private val motionSensorGpio: Gpio = PeripheralManagerService().openGpio(motionSensorPin) fun

    start() { motionSensorGpio.setDirection(Gpio.DIRECTION_IN) motionSensorGpio.setActiveType(Gpio.ACTIVE_HIGH) motionSensorGpio.setEdgeTriggerType(Gpio.EDGE_BOTH) motionSensorGpio.registerGpioCallback(object : GpioCallback() { override fun onGpioEdge(gpio: Gpio): Boolean { if (gpio.value) { motionListener.onMotionDetected() } else { motionListener.onMotionStopped() } return true } }) }
  15. Actions on Google Conversational Actions - Two way dialog -

    Your action manages the conversation “Ok Google, Talk to Spelling Master” Direct Actions - Google handles the entire user interaction - You only handle the fufilment “Ok Google, Turn off the Motion Sensing Alarm”
  16. { "actions": [{ "name": "actions.devices", "deviceControl": { }, "fulfillment": {

    "conversationName": "automation" } }], "conversations": { "automation" : { "name": "automation", "url": "https://example.com/google-assistant/endpoint" } } }