https://github.com/mbientlab/metawear-sdk-android
MetaWear Java SDK - Android - Google - Android Studio
https://github.com/mbientlab/metawear-sdk-android
android bluetooth-le java metamotion metawear
Last synced: 2 months ago
JSON representation
MetaWear Java SDK - Android - Google - Android Studio
- Host: GitHub
- URL: https://github.com/mbientlab/metawear-sdk-android
- Owner: mbientlab
- License: other
- Created: 2014-06-09T20:20:13.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T19:25:41.000Z (over 2 years ago)
- Last Synced: 2025-03-21T15:45:20.774Z (11 months ago)
- Topics: android, bluetooth-le, java, metamotion, metawear
- Language: Java
- Homepage: https://mbientlab.com
- Size: 50.5 MB
- Stars: 63
- Watchers: 17
- Forks: 52
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MetaWear Android API
The MetaWear Android API is a library for interacting with [MbientLab's Bluetooth sensor Development boards](https://mbientlab.com/) on an Android device. A minimum of Android 11.0 (SDK 30) is required to use this library, however for the best results, it is recommended that users be on **Android 13 (SDK 33)**.
# Setup
## Adding Compile Dependency
To add the library to your project, first, update the repositories closure to include the MbientLab Ivy Repo in the project's
``build.gradle`` file.
```gradle
repositories {
ivy {
url "https://mbientlab.com/releases/ivyrep"
layout "gradle"
}
}
```
Then, add the compile element to the dependencies closure in the module's ``build.gradle`` file.
```gradle
dependencies {
compile 'com.mbientlab:metawear:4.0.0'
}
```
The library was built on Java 17 but works fine with the built-in Java 11 in Android Studio Eel.
## Declaring the Service
Once your project has synced with the updated Gradle files, declare the MetaWear Bluetooth LE service in the module's *AndroidManifest.xml* file.
```xml
```
## Binding the Service
Lastly, bind the service in your application and retrain a reference to the service's LocalBinder class. This can be done in any activity or fragment that needs access to a MetaWearBoard object.
```java
import android.app.Activity;
import android.content.*;
import android.os.Bundle;
import android.os.IBinder;
import com.mbientlab.metawear.android.BtleService;
public class ExampleActivity extends Activity implements ServiceConnection {
private BtleService.LocalBinder serviceBinder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
///< Bind the service when the activity is created
getApplicationContext().bindService(new Intent(this, BtleService.class),
this, Context.BIND_AUTO_CREATE);
}
@Override
public void onDestroy() {
super.onDestroy();
///< Unbind the service when the activity is destroyed
getApplicationContext().unbindService(this);
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
///< Typecast the binder to the service's LocalBinder class
serviceBinder = (BtleService.LocalBinder) service;
}
@Override
public void onServiceDisconnected(ComponentName componentName) { }
}
```