The Nuimo controller is an intuitive controller for your computer and connected smart devices. The Nuimo Android SDK helps you to easily integrate your Android apps with Nuimo controllers.
Your Android project must target at least API level 18. Earlier Android versions didn't support Bluetooth Low Energy. So make sure that minSdkVersion
is set at least to 18 or higher in your build.gradle
file.
The Nuimo SDK library for Android is available via the jCenter repository. To include the Nuimo library in your Android app dependencies you need to add two dependency lines to your build.gradle
:
dependencies {
...
compile "com.senic:nuimo-android:0.7.1@aar"
compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.4"
}
If you're wondering why kotlin-stdlib
is needed: The Nuimo library is written in the Kotlin programming language instead of Java. If you are already writing your Android apps in Kotlin then there's no need for this extra line.
The Nuimo library makes it very easy to connect your Android apps with Nuimo controllers. It only takes three steps and a very few lines of code to discover your Nuimo and receive gesture events:
-
Add a
NuimoDiscoveryListener
to an instance ofNuimoDiscoveryManager
and callstartDiscovery()
. This will discover Nuimo controllers nearby. -
Receive discovered controllers by implementing the listener method
onDiscoverNuimoController
. Here you can- Add an event listener to the discovered controller
- Initiate the Bluetooth connection to the discovered controller by calling
connect()
-
Implement
NuimoControllerListener
's event methodonGestureEvent
to access user events performed with the Nuimo controller.
The following code example demonstrates how to discover, connect and receive gesture events from your Nuimo.
public class MainActivity extends AppCompatActivity implements NuimoDiscoveryListener {
NuimoDiscoveryManager nuimoDiscovery = NuimoDiscoveryManager.init(getApplicationContext());
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
nuimoDiscovery.addDiscoveryListener(this);
nuimoDiscovery.startDiscovery();
}
@Override
public void onDiscoverNuimoController(@NotNull NuimoController nuimoController) {
nuimoDiscovery.stopDiscovery();
nuimoController.addControllerListener(new NuimoListener());
nuimoController.connect();
}
class NuimoListener extends BaseNuimoControllerListener {
@Override
public void onGestureEvent(@NotNull NuimoGestureEvent event) {
System.out.println("Received event: " + event.getGesture() + ": " + event.getValue());
}
}
}
We've provided a ready to checkout Android app that demonstrates discovering, connecting and receiving events from your Nuimo controllers. It also demonstrates how display fancy icons on its LED matrix. Simply clone the Nuimo Android demo repository and open it in Android Studio.
The Nuimo library for Android is much more powerful than the use cases presented above. More details to follow here soon.
Have questions or suggestions? Drop us a mail at developers@senic.com. We'll be happy to hear from you.
The NuimoSwift source code is available under the MIT License.