-
-
Save hitherejoe/db8b807da531c943fdc8d0078557b85e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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