Get headphone state with Snapshot API

suggest change
// Remember to initialize your client as described in the Remarks section
Awareness.SnapshotApi.getHeadphoneState(client)
    .setResultCallback(new ResultCallback<HeadphoneStateResult>() {
        @Override
        public void onResult(@NonNull HeadphoneStateResult headphoneStateResult) {
            if (!headphoneStateResult.getStatus().isSuccess()) {
                Log.e(getClass().getSimpleName(), "Could not get the headphone state.");
                return;
            }
            int state = headphoneStateResult.getHeadphoneState().getState();
            Log.i(getClass().getSimpleName(), "Headphone connection state: " +
                (state == HeadphoneState.PLUGGED_IN));
        }
    });

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents