activity_recognition_flutter 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

activity_recognition_flutter #

pub package

Important #

This package uses the Android Embedding API v2. In order to use this in pre-Flutter 1.12 projects, you need to follow this guide: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects Activity recognition plugin for Android and iOS. Only working while App is running (= not terminated by the user or OS).

Getting Started #

Check out the example directory for a sample app using activity recognition.

Android Permissions #

Add permission to your Android Manifest:

<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />

Add the plugin service inside the <application> tags:

<service android:name="dk.cachet.activity_recognition_flutter.activity.ActivityRecognizedService" />

iOS Permissions #

An iOS app linked on or after iOS 10.0 must include usage description keys in its Info.plist file for the types of data it needs. Failure to include these keys will cause the app to crash. To access motion and fitness data specifically, it must include NSMotionUsageDescription.

Flutter Usage #

import 'package:activity_recognition_flutter/activity_recognition_flutter.dart';
...
ActivityRecognition.activityUpdates()

Data types #

iOS #

| Label | Description | |------------ |----------------------------------------------------------------- | | stationary | A Boolean indicating whether the device is stationary. | | walking | A Boolean indicating whether the device is on a walking person. | | running | A Boolean indicating whether the device is on a running person. | | automotive | A Boolean indicating whether the device is in an automobile. | | cycling | A Boolean indicating whether the device is in a bicycle. | | unknown | A Boolean indicating whether the type of motion is unknown. |

Android #

| Label | Description | |------------ |------------------------------------------------------------- | | IN_VEHICLE | The device is in a vehicle, such as a car. | | ON_BICYCLE | The device is on a bicycle. | | ON_FOOT | The device is on a user who is walking or running. | | RUNNING | The device is on a user who is running. | | STILL | The device is still (not moving). | | TILTING | The device angle relative to gravity changed significantly. | | UNKNOWN | Unable to detect the current activity. | | WALKING | The device is on a user who is walking. |

1.2.0 #

  • Changed package name to dk.cachet.activity_recognition_flutter

1.1.0 #

1.0.0 #

  • Initial re-implementation

example/lib/main.dart

import 'package:activity_recognition_flutter/activity_recognition_flutter.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: StreamBuilder(
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                Activity act = snapshot.data;
                return Text("Your phone is to ${act.confidence}% ${act.type}!");
              }

              return Text("No activity detected.");
            },
            stream: ActivityRecognition.activityUpdates(),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  activity_recognition_flutter: ^1.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:activity_recognition_flutter/activity_recognition_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:activity_recognition_flutter/activity_recognition_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:activity_recognition_flutter/activity_recognition_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:activity_recognition_flutter/activity_recognition_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:activity_recognition_flutter/activity_recognition_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • activity_recognition_flutter that is a package requiring null.

Maintenance suggestions

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test