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

Google Developer Days Poland - Android Things - The IoT Platform for everyone

Rebecca Franks
September 06, 2017

Google Developer Days Poland - Android Things - The IoT Platform for everyone

Rebecca Franks

September 06, 2017
Tweet

More Decks by Rebecca Franks

Other Decks in Technology

Transcript

  1. //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>
  2. //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>
  3. button = new Button("BCM6", Button.LogicState.PRESSED_WHEN_LOW); button.setOnButtonEventListener(new Button.OnButtonEventListener() { @Override public

    void onButtonEvent(final Button button, final boolean pressed) { ledGpio.setValue(pressed); } }); // in onDestroy() button.close();
  4. button = new Button("BCM6", Button.LogicState.PRESSED_WHEN_LOW); button.setOnButtonEventListener(new Button.OnButtonEventListener() { @Override public

    void onButtonEvent(final Button button, final boolean pressed) { ledGpio.setValue(pressed); } }); // in onDestroy() button.close();
  5. button = new Button("BCM6", Button.LogicState.PRESSED_WHEN_LOW); button.setOnButtonEventListener(new Button.OnButtonEventListener() { @Override public

    void onButtonEvent(final Button button, final boolean pressed) { ledGpio.setValue(pressed); } }); // in onDestroy() button.close();
  6. //Get access to the pin PeripheralManagerService service = new PeripheralManagerService();

    ledGpio = service.openGpio("BCM21"); ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW); ledGpio.setValue(true); //Close in onDestroy() ledGpio.close();
  7. //Get access to the pin PeripheralManagerService service = new PeripheralManagerService();

    ledGpio = service.openGpio("BCM21"); ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW); ledGpio.setValue(true); //Close in onDestroy() ledGpio.close();
  8. //Get access to the pin PeripheralManagerService service = new PeripheralManagerService();

    ledGpio = service.openGpio("BCM21"); ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW); ledGpio.setValue(true); //Close in onDestroy() ledGpio.close();
  9. DatabaseReference onlineRef = firebaseDatabase.child(".info/connected"); DatabaseReference isPowerOnRef = firebaseDatabase.child("/online"); onlineRef.addValueEventListener(new ValueEventListener()

    { @Override public void onDataChange(final DataSnapshot dataSnapshot) { if (dataSnapshot.getValue(Boolean.class)) { isPowerOnRef.setValue(true); isPowerOnRef.onDisconnect().setValue(false); } } });
  10. DatabaseReference onlineRef = firebaseDatabase.child(".info/connected"); DatabaseReference isPowerOnRef = firebaseDatabase.child("/online"); onlineRef.addValueEventListener(new ValueEventListener()

    { @Override public void onDataChange(final DataSnapshot dataSnapshot) { if (dataSnapshot.getValue(Boolean.class)) { isPowerOnRef.setValue(true); isPowerOnRef.onDisconnect().setValue(false); } } });