Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to detect an Activity #25

Open
mathiasmoeller opened this issue Mar 4, 2020 · 3 comments
Open

Not able to detect an Activity #25

mathiasmoeller opened this issue Mar 4, 2020 · 3 comments

Comments

@mathiasmoeller
Copy link

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!

@xyd945
Copy link

xyd945 commented Dec 14, 2020

have you got it fixed @mathiasmoeller ?

@SalluMaan
Copy link

any solution ???

@DanSallau
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants