Skip to content

Instantly share code, notes, and snippets.

@hitherejoe
Created July 5, 2016 09:02
Show Gist options
  • Save hitherejoe/db8b807da531c943fdc8d0078557b85e to your computer and use it in GitHub Desktop.
Save hitherejoe/db8b807da531c943fdc8d0078557b85e to your computer and use it in GitHub Desktop.
Awareness.SnapshotApi.getHeadphoneState(mGoogleApiClient)
.setResultCallback(new ResultCallback<HeadphoneStateResult>() {
@Override
public void onResult(@NonNull HeadphoneStateResult headphoneStateResult) {
if (headphoneStateResult.getStatus().isSuccess()) {
HeadphoneState headphoneState =
headphoneStateResult.getHeadphoneState();
int state = headphoneState.getState();
if (state == HeadphoneState.PLUGGED_IN) {
// Headphones plugged in
} else if (state == HeadphoneState.UNPLUGGED) {
// Headphones unplugged
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment