Skip to content

Not able to detect an Activity #25

@mathiasmoeller

Description

@mathiasmoeller

Hello @Aminoid!
I am currently struggling to get the activity recognition to work.
Starting the ActivityRecognition seems to work. I can see the native logs in adb logcat. But the subscribe callback is never called. Also the native logs in the ActivityDetectionBroadcastReceiver.onReceive method are never triggered. It looks like there is never an activity event fired.

I tried it in the Android Emulator as well as on a real device (Oneplus 5t).
Any ideas what the issue could be

My code looks like this:

function getUserActivity() {
  return new Promise((resolve, reject) => {
    const unsubscribe = ActivityRecognition.subscribe(detectedActivities => {
      const mostProbableActivity = detectedActivities.sorted[0];

      if (mostProbableActivity.confidence < CONFIDENCE_THRESHOLD) {
        reject(`getUserActivity: Confidence too low (${mostProbableActivity.confidence})`);
      } else {
        resolve(mapUserActivity(mostProbableActivity.type));
      }
    });

    // Start activity detection
    ActivityRecognition.start(DETECTION_INTERVAL).then(result => {
      console.log('ActivityRecognition started!');
    }).catch(error => {
      console.log('ActivityRecognition failed!', error);
    });

    ...
}

Setup:

  • "react-native": "0.59.5"
  • "react-native-activity-recognition": "^3.2.0"

I had version conflicts so I had to set the following in app/build.gradle

implementation(project(':react-native-activity-recognition')) {
    exclude group: "com.google.android.gms", module: 'play-services-places'
}

Do you have any idea what could cause these issues? Help is very welcome since I desperately need this functionality :)
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions