npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

expo-activity-recognition

v0.3.1

Published

Access system activity recognition

Readme

expo-activity-recognition

A module that provides access to the device activity recognition services, allowing your app to detect the user's current activity such as walking, running, cycling, driving, or being still.

Installation

npx expo install expo-activity-recognition

Configuration

iOS

Add the plugin to your app.json:

{
  "expo": {
    "plugins": [
      [
        "expo-activity-recognition",
        {
          "motionPermission": "Allow $(PRODUCT_NAME) to access your device motion"
        }
      ]
    ]
  }
}

This will add the required NSMotionUsageDescription to your Info.plist.

Android

No additional configuration required for basic usage, but permissions will be requested at runtime on Android Q (API 29) and above.

API

Setup and Teardown

// Setup the activity recognition observer
// interval (Android only): milliseconds between updates (default: 60000ms)
ExpoActivityRecognition.setupObserver(interval?: number): Promise<boolean>

// Remove the activity recognition observer
ExpoActivityRecognition.removeObserver(): Promise<boolean>

Permissions

// Request activity recognition permissions
ExpoActivityRecognition.requestPermissions(): Promise<boolean>

// Check activity recognition permission status
ExpoActivityRecognition.checkPermissions(): Promise<PermissionStatus>

Activity Data

// Get the current activity if available
ExpoActivityRecognition.getCurrentActivity(): Promise<ActivityChangeEventPayload>

// Listen for activity changes
const subscription = ExpoActivityRecognition.addListener('onActivityChange', 
  (data: ActivityChangeEventPayload) => {
    // Handle activity change
  }
);

// Remove the listener when done
subscription.remove();

Types

// Possible activity types
type Activity = 'running' | 'cycling' | 'driving' | 'walking' | 'still' | 'unknown';

// Activity change event payload
type ActivityChangeEventPayload = {
  // The detected activity type
  activity: Activity;
  // Confidence level (0-100)
  // 100: high confidence
  // 75: medium confidence
  // 25: low confidence
  // 0: unknown confidence
  confidence: number;
};

// Permission status
type PermissionStatus = {
  // Current permission status
  // 'authorized': Permission granted
  // 'denied': Permission denied or restricted
  // 'undetermined': Permission not requested yet (iOS only)
  status: 'authorized' | 'denied' | 'undetermined';
};

Example

import ExpoActivityRecognition from 'expo-activity-recognition';
import { useEffect, useState } from 'react';
import { Button, SafeAreaView, StyleSheet, Text, View } from 'react-native';

export default function App() {
  const [currentActivity, setCurrentActivity] = useState<string | null>(null);
  const [permissionStatus, setPermissionStatus] = useState<string | null>(null);

  useEffect(() => {
    // Set up activity change listener
    const listener = ExpoActivityRecognition.addListener("onActivityChange", (params) => {
      setCurrentActivity(params.activity);
    });

    // Check initial permission status
    checkPermissions();

    // Clean up listener on unmount
    return () => {
      listener.remove();
    };
  }, []);

  const checkPermissions = async () => {
    try {
      const { status } = await ExpoActivityRecognition.checkPermissions();
      setPermissionStatus(status);
    } catch (error) {
      setPermissionStatus('error');
    }
  };

  const setupActivityRecognition = async () => {
    try {
      // Request permissions first if not already granted
      if (permissionStatus !== 'authorized') {
        await ExpoActivityRecognition.requestPermissions();
        await checkPermissions();
      }
      
      // Set up the observer
      await ExpoActivityRecognition.setupObserver();
    } catch (error) {
      // Handle setup errors
    }
  };

  return (
    <SafeAreaView style={styles.container}>
      <View style={styles.content}>
        <Text style={styles.status}>
          Permission: {permissionStatus || 'unknown'}
        </Text>
        
        <Text style={styles.status}>
          Current activity: {currentActivity || 'unknown'}
        </Text>
        
        <View style={styles.buttonContainer}>
          <Button
            title="Start Activity Recognition"
            onPress={setupActivityRecognition}
          />
          
          <Button
            title="Get Current Activity"  
            onPress={async () => {
              try {
                const activity = await ExpoActivityRecognition.getCurrentActivity();
                setCurrentActivity(activity.activity);
              } catch (error) {
                // Handle error
              }
            }}
          />
          
          <Button
            title="Stop Recognition"
            onPress={() => ExpoActivityRecognition.removeObserver()}
          />
        </View>
      </View>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff'
  },
  content: {
    flex: 1,
    padding: 20,
    justifyContent: 'center'
  },
  status: {
    fontSize: 18,
    marginBottom: 20
  },
  buttonContainer: {
    marginTop: 20,
    gap: 10
  }
});