Page Summary
-
The HeadphoneFence class is used to create fences based on headphone state.
-
Fences indicating a changing state are momentarily TRUE for about 5 seconds before reverting to FALSE.
-
The
duringmethod creates a fence that is TRUE when headphones are in a specified state (plugged in or unplugged). -
The
pluggingInmethod creates a fence that is momentarily TRUE when headphones are plugged in. -
The
unpluggingmethod creates a fence that is momentarily TRUE when headphones are unplugged.
This class is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services
release, as early as January 2027. There is no direct replacement.
Use this class to create headphone state fences.
Note: Values that indicate a changing state are momentarily FenceState.TRUE
for about 5 seconds, then automatically revert to FenceState.FALSE.
Please be sure to follow the guidelines in the Awareness API Guide .
Public Method Summary
| static AwarenessFence |
during(int headphoneState)
This method is deprecated. The Awareness API is deprecated and will be
turned down in a future Google Play services release, as early as January 2027.
There is no direct replacement.
|
| static AwarenessFence |
pluggingIn()
This method is deprecated. The Awareness API is deprecated and will be
turned down in a future Google Play services release, as early as January 2027.
There is no direct replacement.
|
| static AwarenessFence |
unplugging()
This method is deprecated. The Awareness API is deprecated and will be
turned down in a future Google Play services release, as early as January 2027.
There is no direct replacement.
|
Inherited Method Summary
Public Methods
public static AwarenessFence during (int headphoneState)
This method is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services
release, as early as January 2027. There is no direct replacement.
This fence is in the FenceState.TRUE
state when the headphones are in the specified state.
Parameters
| headphoneState | Valid values are
HeadphoneState.PLUGGED_IN or
HeadphoneState.UNPLUGGED |
|---|
Returns
public static AwarenessFence pluggingIn ()
This method is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services
release, as early as January 2027. There is no direct replacement.
This fence is momentarily (about 5 seconds) in the FenceState.TRUE
state when headphones are plugged in to the device.
Returns
public static AwarenessFence unplugging ()
This method is deprecated.
The Awareness API is deprecated and will be turned down in a future Google Play services
release, as early as January 2027. There is no direct replacement.
This fence is momentarily (about 5 seconds) in the FenceState.TRUE
state when headphones are unplugged from the device.