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

[Britt Barak] When your app’s asleep

[Britt Barak] When your app’s asleep

Presentation from GDG DevFest Ukraine 2017 - the biggest community-driven Google tech conference in the CEE.

Learn more at: https://devfest.gdg.org.ua

Google Developers Group Lviv

October 13, 2017
Tweet

More Decks by Google Developers Group Lviv

Other Decks in Technology

Transcript

  1. Background Color (26+) "ongoing tasks which are critical for a

    user to see at a glance" builder.setColor() Understand the context
  2. • Heads-Up (21+) Understand the context • 25- : ◦

    high priority ◦ ringtone / vibration • 26+: high importance channel
  3. How does it sort? 26+: NotificationChannel metadata: importance 25-: NotificationCompat.Builder.

    • setCategory() defines behaviour when device is in Priority mode • setPriority() PRIORITY_MAX / PRIORITY_HIGH + sound / vibration = enables HeadsUp • addPerson()
  4. 1. Be relevant 2. Be useful 3. Be focused How

    to make users love notifications?
  5. The Power To The Users! • Importance • Sound •

    Lights • Vibration • Show on lockscreen • Override do not disturb
  6. Foreground 108 dp = 72 + 18 + 18 dp

    Can have transparency
  7. shortcuts.xml <shortcut android:shortcutId="..." android:icon="..." android:shortcutShortLabel="..."> <intent ... /> <!-- more

    intents... --> <categories android:name="android.shortcut.conversation" /> </shortcut> Static Shortcuts
  8. ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")

    //... .build(); Dynamic Shortcuts shortcutManager. setDynamicShortcuts(Arrays.asList(shortcut));
  9. Pinned Shortcuts if (shortcutManager.isRequestPinShortcutSupported()) { Intent pinIntent = shortcutManager.createShortcutResultIntent(shortcutInfo); PendingIntent

    onPinnedIntent = PendingIntent.getBroadcast(context, 0, pinIntent, 0); shortcutManager. requestPinShortcut(shortcutInfo, onPinnedIntent.getIntentSender()); }
  10. @Override public void onStartListening() { Tile tile = getQsTile(); //...

    tile.setState(Tile.STATE_ACTIVE); tile.updateTile(); } MyTileService.java
  11. What can it do? • showDialog() - adding context to

    your action. a. b. c. There are some limitations when it comes to a locked device though. When isLocked() returns true, you won’t be able to display a dialog and activities must have set FLAG_SHOW_WHEN_LOCKED to display above the lock screen. The unlockAndRun() method can be used to prompt the user to unlock their device, allowing you to run code (such as displaying a dialog) only after they’ve unlocked their device. startActivityAndCollapse
  12. Users must love u on the background... - Be relevant

    - Notifications styles - Be useful - Notification actions & reply - Be focused - Channels - Notif. badge - Be pretty - Adaptive icons - Be quick - Shortcuts - Quick settings tile