Myo Android SDK – 0.10.0
 All Classes Functions Variables Pages
Getting Started

This page describes what you need to know to get started programming for Myo using the Myo Android Software Development Kit (SDK).

If you prefer to dive directly into source code, take a look at the examples.

Supported Devices

You need a device that supports Bluetooth Low Energy and has Android 4.3 or newer. Such as:

  • Nexus 5
  • Nexus 4
  • Nexus 7 (2013)

Adding the SDK to a Project

You can use either Android Studio or Eclipse to develop an application with the Myo Android SDK.

Minimum Android API Level

The Myo Android SDK requires Android API Level 18 or higher. So, applications using the SDK need to set their minSdkVersion to 18 or higher.

Android Studio

Add the SDK as a dependency in your build.gradle file.

dependencies {
    repositories {
        maven {
            url '<path to Myo SDK folder>/myorepository'


Note: <path to Myo SDK folder> can be an absolute or relative path. However, paths like __~/code/myo-android-sdk-0.10.0__ will not work as the __~__ does not get expanded.


See Managing Projects from Eclipse with ADT.

The Myo SDK declares several components and permissions in its own AndroidManifest.xml file. These must be merged into your application's AndroidManifest.xml. You can enable automatic merging of the library's manifest by putting the following in your application's file:



The following permissions are required by the Myo SDK:

// Required for communicating with the Myo device
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

// Required for sending usage data to Thalmic Labs
<uses-permission android:name="android.permission.INTERNET" />

Using the SDK

Initializing the Hub

The first thing that must be done is initialize the Hub. For example, in the onCreate() method of an Activity that will be using the Hub, add:

Hub hub = Hub.getInstance();
if (!hub.init(this)) {
    Log.e(TAG, "Could not initialize the Hub.");

Managing Myo Devices

The Myo Android SDK comes with a built in Activity for scanning and connecting to particular Myo devices. To show it:

Intent intent = new Intent(context, ScanActivity.class);

Alternatively, you can connect to a nearby Myo programmatically like this:

// Use this instead to connect with a Myo that is very near (ie. almost touching) the device

Locking and Unlocking Myo

Normally, Myo is locked until the user performs the unlock pose. Once the unlock pose is performed, your application will begin receiving pose events until Myo locks itself after a short period of time. There are two policies your application can choose from when it comes to locking.

  • LockingPolicy.STANDARD Using this policy means Myo will be locked until the user performs the unlock pose. This is the default policy.
  • LockingPolicy.NONE Using this policy means you will always receive pose events, regardless of Myo's unlock state.

To set the locking policy for your app:


If your application would like to have more control over locking, you can use the appropriate methods on Myo.

In order to extend the unlock timer on a Myo, simply call:


If your application wants Myo to stay unlocked until explicitly locked, you can do:


Note: In order to lock the Myo once again, your application would need to either do a timed unlock, or lock immediately.

Receiving Events

You need to register a DeviceListener with the Hub in order to receive Myo events. If you don't want to implement the entire interface, you can extend AbstractDeviceListener and override only the methods you care about.

Create the listener:

private DeviceListener mListener = new AbstractDeviceListener() {
    public void onConnect(Myo myo, long timestamp) {
        Toast.makeText(mContext, "Myo Connected!", Toast.LENGTH_SHORT).show();

    public void onDisconnect(Myo myo, long timestamp) {
        Toast.makeText(mContext, "Myo Disconnected!", Toast.LENGTH_SHORT).show();

    public void onPose(Myo myo, long timestamp, Pose pose) {
        Toast.makeText(mContext, "Pose: " + pose, Toast.LENGTH_SHORT).show();

        //TODO: Do something awesome.

Add to the Hub:


If you want to stop receiving events, such as when your Activity is paused, remove the listener that was previously added:


Usage Data

The Myo SDK sends some usage data to Thalmic. To opt out of the data being sent, call:


This can be called at any time. To see whether sending usage data is currently enabled, use:


It is your responsibility to expose a way for users to set this, if desired.

Running the Samples

The Myo SDK includes sample projects for Eclipse and Android Studio.

Android Studio

The minimum Android Studio version required is 1.0.

To import the samples project:

  1. Select Import Project....
  2. Select samples/settings.gradle from the Myo SDK folder, and click OK.

To run the HelloWorld sample:

  1. Select Run > Run 'HelloWorld'.
  2. Select Choose a running device and choose a running device.
  3. Click OK.


To import the HelloWorld, Background, MultipleMyos, and Glass sample projects:

  1. Select File > Import....
  2. Select General > Existing Projects into Workspace.
  3. Choose Select root directory and click Browse....
  4. Select the Eclipse directory in the Myo SDK and click Open.
  5. Confirm Background, Glass, HelloWorld, MultipleMyos, and MyoSdk are checked.
  6. Click Finish.

To run the HelloWorld sample:

  1. Left click on HelloWorld in the Package Explorer.
  2. Select Run > Run.