Git Product home page Git Product logo

sensingkit-android's Introduction

SensingKit-Android Library

An Android library that provides Continuous Sensing functionality to your applications. For more information, please refer to the project website.

Supported Sensors

The following sensor modules are currently supported in SensingKit-Android, (listed in SKSensorModuleType enum):

  • Accelerometer
  • Gravity
  • Linear Acceleration
  • Gyroscope
  • Rotation
  • Magnetometer
  • Ambient Temperature
  • Step Detector
  • Step Counter
  • Light
  • Location
  • Activity
  • Battery
  • Screen Status
  • Audio Recorder
  • Audio Level
  • Bluetooth

Configuring the Library

  • Build the library using the command:
./gradlew build
  • Create an app/libs directory inside your project and copy the generated SensingKitLib/build/outputs/aar/SensingKitLib-release.aar (or the equivalent debug) file there.

  • Edit your app/build.gradle file and add a flatDir entry as shown bellow:

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}
  • In the same app/build.gradle file, add SensingKitLib as a dependency as shown below:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.sensingkit:SensingKitLib-release@aar'
    compile 'com.android.support:appcompat-v7:22.2.1โ€™
    compile 'com.google.android.gms:play-services-location:7.5.0'
}

How to Use this Library

  • Import and init SensingKit into your Activity class as shown bellow:
import org.sensingkit.sensingkitlib.SensingKitLib;

SensingKitLibInterface mSensingKitLib = SensingKitLib.getSensingKitLib(this);
  • Register a sensor module (e.g. a Light sensor) as shown bellow:
mSensingKitLib.registerSensorModule(SKSensorModuleType.LIGHT);
  • Subscribe a sensor data listener:
mSensingKitLib.subscribeSensorDataListener(SKSensorModuleType.LIGHT, new SKSensorDataListener() {
    @Override
    public void onDataReceived(final SKSensorModuleType moduleType, final SKSensorData sensorData) {
        System.out.println(sensorData.getDataInCSV());  // Print data in CSV format
    }
});
  • You can cast the data object into the actual sensor data object in order to access all the sensor data properties:
SKLightData lightData = (SKLightData)sensorData;
  • You can Start and Stop the Continuous Sensing using the following commands:
mSensingKitLib.startContinuousSensingWithSensor(SKSensorModuleType.LIGHT);
mSensingKitLib.stopContinuousSensingWithSensor(SKSensorModuleType.LIGHT);

For a complete description of our API, please refer to the project website.

License

Copyright (c) 2014. Queen Mary University of London
Kleomenis Katevas, [email protected].

This file is part of SensingKit-Android library.
For more information, please visit http://www.sensingkit.org.

SensingKit-Android is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

SensingKit-Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with SensingKit-Android.  If not, see <http://www.gnu.org/licenses/>.

This library is available under the GNU Lesser General Public License 3.0, allowing to use the library in your applications.

If you want to help with the open source project, contact [email protected].

sensingkit-android's People

Contributors

minoskt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensingkit-android's Issues

Lint Errors

Hi, thanks for this great project! I noticed that there were some linting errors that prevented the develop branch of this project from building. I'll try to resolve and send a PR, but wanted to create an issue first.

<?xml version="1.0" encoding="UTF-8"?>
<issues format="4" by="lint 25.3.1">

    <issue
        id="MissingPermission"
        severity="Error"
        message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
        category="Correctness"
        priority="9"
        summary="Missing Permissions"
        explanation="This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs. If the code using those APIs is called at runtime, then the program will crash.

Furthermore, for permissions that are revocable (with targetSdkVersion 23), client code must also be prepared to handle the calls throwing an exception if the user rejects the request for permission at runtime."
        errorLine1="        LocationServices.FusedLocationApi.requestLocationUpdates(mClient, locationRequest, this);"
        errorLine2="        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
        quickfix="studio">
        <location
            file="/SensingKit-Android/SensingKitLib/src/main/java/org/sensingkit/sensingkitlib/sensors/SKLocation.java"
            line="102"
            column="9"/>
    </issue>

    <issue
        id="MissingPermission"
        severity="Error"
        message="Missing permissions required by ActivityRecognitionApi.requestActivityUpdates: com.google.android.gms.permission.ACTIVITY_RECOGNITION"
        category="Correctness"
        priority="9"
        summary="Missing Permissions"
        explanation="This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs. If the code using those APIs is called at runtime, then the program will crash.

Furthermore, for permissions that are revocable (with targetSdkVersion 23), client code must also be prepared to handle the calls throwing an exception if the user rejects the request for permission at runtime."
        errorLine1="        mActivityRecognition.requestActivityUpdates(mClient, 0, mRecognitionPendingIntent);"
        errorLine2="        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
        quickfix="studio">
        <location
            file="/SensingKit-Android/SensingKitLib/src/main/java/org/sensingkit/sensingkitlib/sensors/SKMotionActivity.java"
            line="161"
            column="9"/>
    </issue>

    <issue
        id="MissingPermission"
        severity="Error"
        message="Missing permissions required by ActivityRecognitionApi.removeActivityUpdates: com.google.android.gms.permission.ACTIVITY_RECOGNITION"
        category="Correctness"
        priority="9"
        summary="Missing Permissions"
        explanation="This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs. If the code using those APIs is called at runtime, then the program will crash.

Furthermore, for permissions that are revocable (with targetSdkVersion 23), client code must also be prepared to handle the calls throwing an exception if the user rejects the request for permission at runtime."
        errorLine1="        mActivityRecognition.removeActivityUpdates(mClient, mRecognitionPendingIntent);"
        errorLine2="        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
        quickfix="studio">
        <location
            file="/SensingKit-Android/SensingKitLib/src/main/java/org/sensingkit/sensingkitlib/sensors/SKMotionActivity.java"
            line="166"
            column="9"/>
    </issue>

    <issue
        id="GradleDependency"
        severity="Warning"
        message="A newer version of com.google.android.gms:play-services-location than 10.2.0 is available: 10.2.1"
        category="Correctness"
        priority="4"
        summary="Obsolete Gradle Dependency"
        explanation="This detector looks for usages of libraries where the version you are using is not the current stable release. Using older versions is fine, and there are cases where you deliberately want to stick with an older version. However, you may simply not be aware that a more recent version is available, and that is what this lint check helps find."
        errorLine1="    compile &apos;com.google.android.gms:play-services-location:10.2.0&apos;"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
        quickfix="studio">
        <location
            file="/SensingKit-Android/SensingKitLib/build.gradle"
            line="24"
            column="5"/>
    </issue>

    <issue
        id="StaticFieldLeak"
        severity="Warning"
        message="Do not place Android context classes in static fields (static reference to `SKSensorManager` which has field `mApplicationContext` pointing to `Context`); this is a memory leak (and also breaks Instant Run)"
        category="Performance"
        priority="6"
        summary="Static Field Leaks"
        explanation="A static field will leak contexts."
        errorLine1="    private static SKSensorManager sSensorManager;"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="/SensingKit-Android/SensingKitLib/src/main/java/org/sensingkit/sensingkitlib/SKSensorManager.java"
            line="39"
            column="5"/>
    </issue>

    <issue
        id="StaticFieldLeak"
        severity="Warning"
        message="Do not place Android context classes in static fields (static reference to `SensingKitLib` which has field `mApplicationContext` pointing to `Context`); this is a memory leak (and also breaks Instant Run)"
        category="Performance"
        priority="6"
        summary="Static Field Leaks"
        explanation="A static field will leak contexts."
        errorLine1="    private static SensingKitLib sSensingKitLib;"
        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="/SensingKit-Android/SensingKitLib/src/main/java/org/sensingkit/sensingkitlib/SensingKitLib.java"
            line="34"
            column="5"/>
    </issue>

</issues>

Got stack overflow error

I encountered stack over flow error while registering for sensor module. please help me out..
Following is the error I got:
java.lang.StackOverflowError: stack size 8MB
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.getSensorModule(SensorModuleManager.java:117)
at org.sensingkit.sensingkitlib.modules.SensorModuleManager.isSensorModuleRegistered(SensorModuleManager.java:103)
at org.sensingkit.sensingkitlib.modules.Sens

Thank you..

Runtime exception: Unsupported SKBatteryHealth with code

Describe the bug
Library is throwing runtime exception on some devices Unsupported SKBatteryHealth with code:

To Reproduce
Reproduceable on samsung phone with API level 9.0

Expected behavior
In case of code '9' error should not be thrown.

Smartphone (please complete the following information):

  • Device: [Samsung Galaxy S8]
  • OS: Android
  • Version [9.0 (Pie)]

Stack Trace

Caused by java.lang.RuntimeException: Unsupported SKBatteryHealth with code: 9
       at org.sensingkit.sensingkitlib.data.SKBatteryStatusData$SKBatteryHealth.valueOf(SKBatteryStatusData.java:262)
       at org.sensingkit.sensingkitlib.data.SKBatteryStatusData.<init>(SKBatteryStatusData.java:314)
       at org.sensingkit.sensingkitlib.sensors.SKBatteryStatus$1.onReceive(SKBatteryStatus.java:67)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.