react-native-activity-recognition
react-native-activity-recognition copied to clipboard
Not able to detect an Activity
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!
have you got it fixed @mathiasmoeller ?
any solution ???
@mathiasmoeller , @SalluMaan @xyd945 please is there any solution to this ?