Aminoid / react-native-activity-recognition

React Native wrapper for the Activity Recognition API.
GNU General Public License v2.0
95 stars 79 forks source link

Not able to detect an Activity #25

Open mathiasmoeller opened 4 years ago

mathiasmoeller commented 4 years ago

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:

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!

xyd945 commented 3 years ago

have you got it fixed @mathiasmoeller ?

SalluMaan commented 3 years ago

any solution ???

DanSallau commented 3 years ago

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