1

I am busy building a react-native app.

I am a bit stuck with my next task and not quite sure where to start.

In the app, if you as the user are driving a pop up modal should open to say that 'It appears that you are driving, pull over for safety' (something like that).

My question is: Is there a package that can detect if a user is driving?? I saw the react-native-activity-recognition package but the documentation is a bit confusing.

-> If using this package how would i included the popup modal with it??

Has anyone implemented something similar?? And if you have can you please point me into the right direction.

Thank You

  • Please look at this https://stackoverflow.com/questions/43996944/is-it-possible-to-track-acceleration-and-speed-using-gps-data as it has already been answered – Ansh Dec 09 '22 at 09:09
  • Does this answer your question? [Is it possible to track acceleration and speed using gps data?](https://stackoverflow.com/questions/43996944/is-it-possible-to-track-acceleration-and-speed-using-gps-data) – Ansh Dec 09 '22 at 09:10
  • No Not really. I don't need to track speed. I just need to track movement basically and if there is a specific amount of movement then the modal should pop up – Jennifer De Goede Dec 09 '22 at 11:33

1 Answers1

0

From documentation to https://github.com/Aminoid/react-native-activity-recognition

import ActivityRecognition from 'react-native-activity-recognition'

...

// Subscribe to updates on mount

  useEffect(() => {
    ActivityRecognition.subscribe(detectedActivities => {
      const mostProbableActivity = detectedActivities.sorted[0];
      console.log(mostProbableActivity);
    });

// Stop activity detection and remove the listener on unmount

    return ActivityRecognition.stop();
  });

...

// Start activity detection

const detectionIntervalMillis = 1000
ActivityRecognition.start(detectionIntervalMillis)

detectedActivities is an array of objects [{type: "WALKING", confidence: 2}] where type can be for IOS:

  • RUNNING
  • WALKING
  • STATIONARY
  • AUTOMOTIVE
  • CYCLING
  • UNKNOWN
Kirill Novikov
  • 2,576
  • 4
  • 20
  • 33