Snapshot API - ResultCallBack not triggered

103 views Asked by At

I am using the Google Snapshot API in Android.

I use this code to get the user's activity and store it to Firebase.

//Get user's current activity
private void myCurrentActivity(final String timestamp) {
    if (checkPermission()) {
        Awareness.SnapshotApi.getDetectedActivity(mGoogleApiClient)
                .setResultCallback(new ResultCallback<DetectedActivityResult>() {
                    @Override
                    public void onResult(@NonNull DetectedActivityResult detectedActivityResult) {
                        if (detectedActivityResult.getStatus().isSuccess()) {
                            Log.d(TAG, "myCurrentActivity - SUCCESS");
                            ActivityRecognitionResult activityRecognitionResult = detectedActivityResult.getActivityRecognitionResult();
                            databaseReference.child(getUID(getApplicationContext(), "myCurrentActivity")).child(timestamp).child("activity").setValue(getActivityString(activityRecognitionResult.getMostProbableActivity().getType()));
                            Log.d(TAG, "Most Propable Activity : " + getActivityString(activityRecognitionResult.getMostProbableActivity().getType()));
                        } else {
                            Log.d(TAG, "myCurrentActivity - FAILURE");
                            databaseReference.child(getUID(getApplicationContext(), "myCurrentActivity")).child(timestamp).child("activity").setValue("null");
                        }
                    }
                });
    }
}

The problem is that the onResult function is never executed when i run it.

Do you have any ideas what may cause this ?

Thank you.

EDIT: I just ran it in the emulator and it's working without problems. Is it possible that this has something to do with my device ?

0

There are 0 answers