react-native-activity-recognition icon indicating copy to clipboard operation
react-native-activity-recognition copied to clipboard

Not able to detect an Activity

Open mathiasmoeller opened this issue 5 years ago • 3 comments

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!

mathiasmoeller avatar Mar 04 '20 14:03 mathiasmoeller

have you got it fixed @mathiasmoeller ?

xyd945 avatar Dec 14 '20 14:12 xyd945

any solution ???

SalluMaan avatar Apr 26 '21 10:04 SalluMaan

@mathiasmoeller , @SalluMaan @xyd945 please is there any solution to this ?

DanSallau avatar Jun 15 '21 22:06 DanSallau