Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Connecting your phone and home with firebase and android things - James Coggan, MyDrive
1. James Coggan, MyDrive Solutions
Connect your Phone and Home
with
Firebase and Android Things
We are hiring!
https://www.mydrivesolutions.com/jobs
Q&A
sli.do
#thingstelaviv
2. A little bit about me..
James Coggan
Android tech lead
https://jamescoggan.com
@mad_team
27. val pinName = gpioForLED
ledGpio = pioService.openGpio(pinName)
...
val pinName = gpioForButton
button = ButtonInputDriver(
pinName,
Button.LogicState.PRESSED_WHEN_LOW,
KeyEvent.KEYCODE_SPACE)
...
28.
29.
30.
31. Setting up Firebase
https://console.firebase.google.com
● Create a new Firebase project
● Add a new Android app to the project with your
package name: ie: com.jamescoggan.thingspresentation
● Enable anonymous login on (temporarily)
32. ● Setup a database
// Database
{
"light" : true
}
● Add the rules
// Rules - don’t expose your data for the world
{
"rules": {
".write": "auth != null",
".read": "auth != null",
}
}
33. // Base build.gradle for all modules
buildscript {
...
dependencies {
classpath "com.google.gms:google-services:$googleServicesClassVersion"
}
}
35. // MainActivity.kt (Both modules - mobile and things)
override fun onCreate(savedInstanceState: Bundle?) {
FirebaseApp.initializeApp(this) // Move me to the Application class
val firebaseAuth = FirebaseAuth.getInstance()
val databaseReference = FirebaseDatabase.getInstance().reference
}
36. // MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
...
val databaseReference = FirebaseDatabase.getInstance().reference
firebaseAuth.signInAnonymously()
.addOnCompleteListener { task ->
if (task.isSuccessful) {
observeLightsData()
} else {
Timber.e(task.exception, "FirebaseAuth:failed")
}
}
}