Secondary Screen Support Using DisplayManager

5,695 views

Published on

from the 2013 Samsung Developer Conference

Published in: Technology, Business
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,695
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
93
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Secondary Screen Support Using DisplayManager

  1. 1. Secondary Screen Support Using DisplayManager Copyright © 2013 CommonsWare, LLC
  2. 2. Who's On Second? ● Auxiliary screen ● Inconsistently available ● Display-only (no touchscreen) ● Not: – Simply being on a TV (think OUYA) – Devices with dual primary displays (SONY Tablet P) Copyright © 2013 CommonsWare, LLC
  3. 3. Getting To Second: Sending ● HDMI ● Mobile High-Definition Link (MHL, SlimPort) ● Proprietary Cable ● Miracast/AllShare Cast – WifiDirect-based display protocol – Available on many modern devices, including most of the Samsung Galaxy line Copyright © 2013 CommonsWare, LLC
  4. 4. Getting to Second: Receiving ● HDMI – – ● Direct Via MHL adapter Miracast/AllShare Cast – Direct (e.g., most of Samsung Smart TVs) – Via HDMI adapter Copyright © 2013 CommonsWare, LLC
  5. 5. Secondary Display: What Is Shown ● Android 1.0 through 2.3 – – ● Generally nothing Sporadic device-specific support (e.g., HTC DROID Incredible and composite output) Android 3.0 through 4.1 – – ● Mirroring Some limited developer control (video players) Android 4.2+: Developer Control – At least for devices that shipped with 4.2+ Copyright © 2013 CommonsWare, LLC
  6. 6. Not All Screens Are Created Equal ● Key Differences – – ● Size (720p, 1080p, etc.) Density (tvdpi, hdpi, etc.) Net: Different Context for Different Display – Inflate layouts, load resources, etc. using proper Context to get the right ones for the targeted display Copyright © 2013 CommonsWare, LLC
  7. 7. Exerting Your Control ● Presentation – Subclass of Dialog, added in API Level 17 – Override onCreate(), call setContentView() – Supplies Context suitable for use with designated Display – When displayed using show(), appears on designated Display Copyright © 2013 CommonsWare, LLC
  8. 8. Exerting Your Control ● CWAC-Presentation and PresentationHelper – Lets you know when a secondary display becomes available or goes away – Usage ● Create instance ● Supply a Context and a Listener ● Forward onPause() / onResume() ● Implement showPreso() / clearPreso() Copyright © 2013 CommonsWare, LLC
  9. 9. Trying It Out ● Testing Options – Actual “secondary screen” – Simulated secondary display ● Developer Options → Simulate secondary displays ● Works well with hardware, less so with x86 emulator Copyright © 2013 CommonsWare, LLC
  10. 10. Copyright © 2013 CommonsWare, LLC
  11. 11. Copyright © 2013 CommonsWare, LLC
  12. 12. Low-Level Exertion ● DisplayManager – System service (DISPLAY_SERVICE) – getDisplays() (all or those in a category, like DISPLAY_CATEGORY_PRESENTATION) – registerDisplayListener() to find out about changes in mix of displays – New to API Level 17 Copyright © 2013 CommonsWare, LLC
  13. 13. Low-Level Exertion ● MediaRouter – System service (MEDIA_ROUTER_SERVICE) – More general: find preferred “route” for audio or video – getSelectedRoute() to find the route to be used right now (ROUTE_TYPE_LIVE_VIDEO) – addCallback() to find out route changes – Added in API Level 16 Copyright © 2013 CommonsWare, LLC
  14. 14. Fragments of a Presentation ● Good News! – – ● Presentation extends Dialog, so DialogFragment works DialogFragment supports either show-as-dialog or show-as-regular-fragment Bad News! – Since different Contexts, cannot use the same DialogFragment instance for each Copyright © 2013 CommonsWare, LLC
  15. 15. Secondary Screen Strategies ● Secondary Screen: Not a Touchscreen – ● Whatever shows on secondary screen is driven and controlled by what is on the primary screen Example: Video Player – Second screen shows the video playback – Primary screen has play/pause, fast-forward, rewind, SeekBar, IMDB content, chat screen, etc. Copyright © 2013 CommonsWare, LLC
  16. 16. Secondary Screen Strategies ● Must Have Secondary Screen – ● Optional, Dedicated UX – ● Presentation-specific app Game using second screen for primary output, device screen for control surface and secondary output Optional, Using Fragments – Push stuff to second screen or show “inline” Copyright © 2013 CommonsWare, LLC
  17. 17. Secondary Screen Tactics ● Separate Fragments/Views – – ● One for what is shown One for controlling what is shown Mirroring Content – Same fragment/view, shown on both displays, controlled by primary screen Copyright © 2013 CommonsWare, LLC
  18. 18. Limitations and Annoyances ● Activity-Based – Presentation extends Dialog, must have an activity to show a Dialog – Cannot have second screen driven by service, with primary screen running something independent – Samsung, multi-window apps, and secondary screens? Copyright © 2013 CommonsWare, LLC
  19. 19. Limitations and Annoyances ● Activity-Based – Must dismiss() Presentation as part of switching to a new activity → flicker ● Briefly shows mirroring before new Presentation appears – Similar flicker if you try switching from one Presentation to another – General rule: one activity and one Presentation, just updating content Copyright © 2013 CommonsWare, LLC

×