Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.