Prerequisites
- Activate your profile & your Notches first. If you need help follow the activation docs
- Navigate to Dashboard / [Your application name] / Credentials
- Set up your build.gradle file.
- Copy the credentials from the developer page.
repositories { jcenter() maven { url 'https://wearnotch.com/maven/notch/' credentials { username {yourUserName} password {yourPassword} } } }
-
Reference our SDK & application config under your android settings in your application build.gradle
configurations { appConfig } dependencies { implementation 'com.notch.sdk:sdk-android:{latest_version_number}' appConfig 'com.notch.sdk:sdk-android:{latest_version_number}' }
Latest version is available in the changelogs
- Add the following custom tasks to the same application build.gradle just below the dependencies. This will merge our 3D model with the material file.
task convertObj(type: JavaExec) {
ext.srcFile1 = file('../model/equipment_tutorial.obj')
ext.srcFile2 = file('../model/equipment_tutorial.js')
inputs.files files(srcFile1,srcFile2)
outputs.dir project.modelAssetsDir
main = 'com.wearnotch.visualiserutil.ObjConverter'
classpath = configurations.appConfig
args = [ srcFile1.getAbsolutePath(), srcFile2.getAbsolutePath(),
new File((File) project.modelAssetsDir, 'equipment.dat').getAbsolutePath() ]
}
task convertMtl(type: JavaExec) {
ext.srcFile = file('../model/equipment_tutorial.mtl')
inputs.file srcFile
outputs.dir project.modelAssetsDir
main = 'com.wearnotch.visualiserutil.MtlConverter'
classpath = configurations.appConfig
args = [ srcFile.getAbsolutePath(),
new File((File) project.modelAssetsDir, 'equipment_mtl.dat').getAbsolutePath() ]
}
project.afterEvaluate {
project.tasks.findAll {
it.name.startsWith('generate') && it.name.endsWith('Assets')
}.each {
it.dependsOn convertObj
it.dependsOn convertMtl
}
}
Usage
Manifest
Edit your permissions first in your Manifest to grant your app BLE connection & internet access:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
Allow the notch service to run in the background:
<service android:name="com.wearnotch.service.NotchAndroidService" />
Starting the service
On application launch (or wherever you wish) start the service:
-
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val controlServiceIntent = Intent(this, NotchAndroidService::class.java) startService(controlServiceIntent) bindService(controlServiceIntent, this, Context.BIND_AUTO_CREATE) } override fun onServiceConnected(name: ComponentName?, service: IBinder?) { if (service instanceof NotchService) { notchService = (NotchService) service; } // Start using the SDK }
Request permissions
Before using the notch devices, make sure the user was granted appropriate permissions granted. Otherwise, the phone won’t find any Notches.
You can find code examples in our Android Tutorial application.