public final class DisplayManager extends Object
Get an instance of this class by calling
Context.getSystemService()
with the argument
Context.DISPLAY_SERVICE
.
Modifier and Type | Class and Description |
---|---|
static interface |
DisplayManager.DisplayListener
Listens for changes in available display devices.
|
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_WIFI_DISPLAY_STATUS_CHANGED
Broadcast receiver that indicates when the Wifi display status changes.
|
static String |
DISPLAY_CATEGORY_PRESENTATION
Display category: Presentation displays.
|
static String |
EXTRA_WIFI_DISPLAY_STATUS
Contains a
WifiDisplayStatus object. |
Constructor and Description |
---|
DisplayManager(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
connectWifiDisplay(String deviceAddress)
Connects to a Wifi display.
|
void |
disconnectWifiDisplay()
Disconnects from the current Wifi display.
|
void |
forgetWifiDisplay(String deviceAddress)
Forgets a previously remembered Wifi display.
|
Display |
getDisplay(int displayId)
Gets information about a logical display.
|
Display[] |
getDisplays()
Gets all currently valid logical displays.
|
Display[] |
getDisplays(String category)
Gets all currently valid logical displays of the specified category.
|
WifiDisplayStatus |
getWifiDisplayStatus()
Gets the current Wifi display status.
|
void |
registerDisplayListener(DisplayManager.DisplayListener listener,
Handler handler)
Registers an display listener to receive notifications about when
displays are added, removed or changed.
|
void |
renameWifiDisplay(String deviceAddress,
String alias)
Renames a Wifi display.
|
void |
scanWifiDisplays()
Initiates a fresh scan of availble Wifi displays.
|
void |
unregisterDisplayListener(DisplayManager.DisplayListener listener)
Unregisters an input device listener.
|
public static final String ACTION_WIFI_DISPLAY_STATUS_CHANGED
The status is provided as a WifiDisplayStatus
object in the
EXTRA_WIFI_DISPLAY_STATUS
extra.
This broadcast is only sent to registered receivers and can only be sent by the system.
public static final String EXTRA_WIFI_DISPLAY_STATUS
WifiDisplayStatus
object.public static final String DISPLAY_CATEGORY_PRESENTATION
This category can be used to identify secondary displays that are suitable for use as presentation displays.
public DisplayManager(Context context)
public Display getDisplay(int displayId)
displayId
- The logical display id.public Display[] getDisplays()
public Display[] getDisplays(String category)
When there are multiple displays in a category the returned displays are sorted
of preference. For example, if the requested category is
DISPLAY_CATEGORY_PRESENTATION
and there are multiple presentation displays
then the displays are sorted so that the first display in the returned array
is the most preferred presentation display. The application may simply
use the first display or allow the user to choose.
category
- The requested display category or null to return all displays.DISPLAY_CATEGORY_PRESENTATION
public void registerDisplayListener(DisplayManager.DisplayListener listener, Handler handler)
listener
- The listener to register.handler
- The handler on which the listener should be invoked, or null
if the listener should be invoked on the calling thread's looper.unregisterDisplayListener(android.hardware.display.DisplayManager.DisplayListener)
public void unregisterDisplayListener(DisplayManager.DisplayListener listener)
listener
- The listener to unregister.registerDisplayListener(android.hardware.display.DisplayManager.DisplayListener, android.os.Handler)
public void scanWifiDisplays()
ACTION_WIFI_DISPLAY_STATUS_CHANGED
broadcast.public void connectWifiDisplay(String deviceAddress)
ACTION_WIFI_DISPLAY_STATUS_CHANGED
broadcast.
Automatically remembers the display after a successful connection, if not already remembered.
Requires android.Manifest.permission#CONFIGURE_WIFI_DISPLAY
to connect
to unknown displays. No permissions are required to connect to already known displays.
deviceAddress
- The MAC address of the device to which we should connect.public void disconnectWifiDisplay()
ACTION_WIFI_DISPLAY_STATUS_CHANGED
broadcast.public void renameWifiDisplay(String deviceAddress, String alias)
The display must already be remembered for this call to succeed. In other words, we must already have successfully connected to the display at least once and then not forgotten it.
Requires android.Manifest.permission#CONFIGURE_WIFI_DISPLAY
.
deviceAddress
- The MAC address of the device to rename.alias
- The alias name by which to remember the device, or null
or empty if no alias should be used.public void forgetWifiDisplay(String deviceAddress)
Automatically disconnects from the display if currently connected to it.
Requires android.Manifest.permission#CONFIGURE_WIFI_DISPLAY
.
deviceAddress
- The MAC address of the device to forget.public WifiDisplayStatus getWifiDisplayStatus()
ACTION_WIFI_DISPLAY_STATUS_CHANGED
.