This library pairs with SensorDataTransporterHandheld to achieve a connection between an Android Mobile Device
with the SmartWatch Device
Initialize the helper
val sensorDataTransporter = SensorDataTransporterWearable(applicationContext)
sensorDataTransporter.initStepCounterSensor()
sensorDataTransporter.initHeartRateSensor()
sensorDataTransporter.initGyroscopeSensor()
sensorDataTransporter.initAccelerometerSensor()
sensorDataTransporter.registerBroadcastReceiver()
sensorDataTransporter.unRegisterBroadcastReceiver()
-
The
smartwatch
app and thehandheld
app must have the samepackage
name and must be signed with the samekeystore
-
You have to add this service inside
<application> .. </application>
tag
<service
android:name="com.damnluck.sensordatatransporterwearable.core.MessageReceiverWear"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<data android:scheme="wear" android:host="*" android:pathPrefix="/startHeartRate" />
<data android:scheme="wear" android:host="*" android:pathPrefix="/stopHeartRate"/>
<data android:scheme="wear" android:host="*" android:pathPrefix="/startAccelerometer" />
<data android:scheme="wear" android:host="*" android:pathPrefix="/stopAccelerometer"/>
<data android:scheme="wear" android:host="*" android:pathPrefix="/startGyroscope" />
<data android:scheme="wear" android:host="*" android:pathPrefix="/stopGyroscope"/>
<data android:scheme="wear" android:host="*" android:pathPrefix="/getStepCount"/>
</intent-filter>
</service>
- Also, you have add important dependencies in your gradle file
implementation 'com.google.android.gms:play-services-wearable:17.1.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
Now the app is ready to receive messages from the handheld to start sending sensor data.