You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -38,10 +39,23 @@ The library has the following requirements:
38
39
- An Android WearOS smartwatch running WearOS 1.0 (API level 23) or higher. In addition, the smartwatch must
39
40
be paired with a smartphone with the counterpart application installed.
40
41
41
-
> **Warning**: Both applications (smartwatch and smartphone apps) must have the same [application id](https://developer.android.com/studio/build/configure-app-module#set-application-id).
42
+
> [!IMPORTANT]
43
+
> Both applications (smartwatch and smartphone apps) must have the same [application id](https://developer.android.com/studio/build/configure-app-module#set-application-id).
42
44
> If that's not the case, the applications will not be able to interact.
43
45
44
-
> **Note**: Don't forget to check the requirements of [_nativescript-wearos-sensors_](https://github.com/GeoTecINIT/nativescript-wearos-sensors) too.
46
+
> [!TIP]
47
+
> Don't forget to check the requirements of [_nativescript-wearos-sensors_](https://github.com/GeoTecINIT/nativescript-wearos-sensors) too.
48
+
49
+
### Tested WearOS versions and devices
50
+
The library has been tested in the following WearOS versions:
51
+
52
+
-**Wear OS 2.33** (Android 9 - API 28):
53
+
- TicWatch Pro 3 GPS
54
+
-**Wear OS 3.5** (Android 11 - API 30):
55
+
- TicWatch Pro 3 GPS
56
+
- TicWatch Pro 5
57
+
-**WearOS 4** (Android 13 - API 33):
58
+
- Samsung Watch4
45
59
46
60
## Usage
47
61
The library offers two main features:
@@ -61,17 +75,34 @@ The library offers two main features:
61
75
<details>
62
76
<summary>Heart rate</summary>
63
77
78
+
You **must** add the following permission to the manifest:
-[Messaging](#messaging): it allows to send and receive simple messages between both devices.
@@ -90,7 +121,13 @@ has to grant some permissions. The library handles this situation (i.e., when pe
90
121
launches a notification to warn the user that some permissions need to be granted. However, we **do not**
91
122
provide a mechanism to ask the permissions, we delegate that task on the developer. Why? To customise the
92
123
way the permissions are required. In other words, the developer has to provide a class reference of an
93
-
activity for requesting permissions using the [`PermissionsManager`](#permissionsmanager), and the library
124
+
activity for requesting permissions using the [`PermissionsManager.setPermissionsActivity()`](#permissionsmanager). There are two
125
+
ways of requesting permissions:
126
+
127
+
- If the data collection is started using the paired smartphone, the permissions will be automatically requested. You have to do nothing!
128
+
- If the data collection is started from the smartphone, you should check that the necessary permissions are granted using the [`PermissionsManager.launchPermissionsRequestIfNeeded()`](#permissionsmanager)
129
+
130
+
and the library
94
131
will start that activity when any permission is required and the user taps into the notification warning.
95
132
96
133
We have tried to make it easy for you to implement that activity:
@@ -129,13 +166,19 @@ public class YourRequestPermissionsActivity extends FragmentActivity {
129
166
}
130
167
```
131
168
169
+
If your app runs in WearOS 4+, the `POST_NOTIFICATIONS` permission will be required. To do so, we also
170
+
provide the [`PermissionsManager.launchRequiredPermissionsRequest()`](#permissionsmanager).
171
+
132
172
Finally, here is a sample on how to setup your activity for requesting permissions:
@@ -185,8 +232,9 @@ public class MainActivity extends Activity {
185
232
}
186
233
```
187
234
188
-
> **Note**: Here we are using [`Sensor`](#sensor) and [`CollectionConfiguration`](#collectionconfiguration)
189
-
> from [_background-sensors_](https://github.com/GeoTecINIT/BackgroundSensors).
235
+
> [!TIP]
236
+
> Here we are using [`Sensor`](#sensor) and [`CollectionConfiguration`](#collectionconfiguration)
237
+
> from [_Background Sensors_](https://github.com/GeoTecINIT/BackgroundSensors).
190
238
> Check its documentation for more information.
191
239
192
240
### Messaging
@@ -228,9 +276,10 @@ public class MainActivity extends Activity {
228
276
}
229
277
```
230
278
231
-
> **Note**: you can find a full sample of all these features in the [MainActivity](app/src/main/java/es/uji/geotec/wearossensorsdemo/MainActivity.java)
232
-
and [RequestPermissionsActivity](app/src/main/java/es/uji/geotec/wearossensorsdemo/RequestPermissionsActivity.java) activities
233
-
of the demo application.
279
+
> [!TIP]
280
+
> You can find a full sample of all these features in the [MainActivity](app/src/main/java/es/uji/geotec/wearossensorsdemo/MainActivity.java)
281
+
> and [RequestPermissionsActivity](app/src/main/java/es/uji/geotec/wearossensorsdemo/RequestPermissionsActivity.java) activities
282
+
> of the demo application.
234
283
235
284
## API
236
285
@@ -243,17 +292,23 @@ of the demo application.
243
292
|`HEART_RATE`| Represents the heart rate monitor. |
244
293
|`LOCATION`| Represents the GPS. |
245
294
295
+
Each sensor provide the `getRequiredPermissions()` method to obtain the permissions that need to be
296
+
requested for the specified sensor. Use it along `PermissionsManager.launchPermissionsRequestIfNeeded()`.
297
+
246
298
### `SensorManager`
247
-
Refer to the [_background-sensors_](https://github.com/GeoTecINIT/BackgroundSensors#sensormanager) documentation.
299
+
Refer to the [_Background Sensors_](https://github.com/GeoTecINIT/BackgroundSensors#sensormanager) documentation.
|`permissionsToRequestFromIntent(Intent intent)`|`ArrayList<String>`| Permissions to request in the custom request permissions activity. |
253
-
|`permissionsToBeRequested(Context context, ArrayList<String> required)`|`ArrayList<String>`| Returns the permissions that need to be requested (internal use only). |
254
-
|`requestPermissions(Activity activity, ArrayList<String> permissions)`|`void`| Request the specified permissions previously obtained from `permissionsToRequestFromIntent`. You should call this method in your custom request permissions activity. |
255
-
|`setPermissionsActivity(Context context, Class<?> permissionsActivity)`|`void`| Sets up the class that will be used for requesting permissions. You should call this method in your MainActivity class once your app has started. |
256
-
|`getPermissionsActivity(Context context)`|`Class<?>`| Gets the class that will be used for requesting permissions. |
|`permissionsToRequestFromIntent(Intent intent)`|`ArrayList<String>`| Permissions to request in the custom request permissions activity. |
305
+
|`specialPermissionsToRequestFromIntent(Intent intent)`|`ArrayList<String>`| Special permissions to request in the custom request permissions activity. |
306
+
|`launchRequiredPermissionsRequest(Activity activity)`|`void`| Launch the permissions activity to request the required permission to post notifications (only WearOS 4+). |
307
+
|`launchPermissionsRequestIfNeeded(Activity activity, ArrayList<String> permissions)`|`boolean`| Launch the permissions activity to request the specified permissions. Call this method to request the permissions for a specified sensor. Returns `true` if the permissions activity has been launched. |
308
+
|`permissionsToBeRequested(Context context, ArrayList<String> required)`|`ArrayList<String>`| Returns the permissions that need to be requested (internal use only). |
309
+
|`requestPermissions(Activity activity, ArrayList<String> permissions)`|`void`| Request the specified permissions previously obtained from `permissionsToRequestFromIntent`. You should call this method in your custom request permissions activity. |
310
+
|`setPermissionsActivity(Context context, Class<?> permissionsActivity)`|`void`| Sets up the class that will be used for requesting permissions. You should call this method in your MainActivity class once your app has started. |
311
+
|`getPermissionsActivity(Context context)`|`Class<?>`| Gets the class that will be used for requesting permissions. |
0 commit comments