Commit e691d50b authored by Angelo Coiro's avatar Angelo Coiro

Update android.md

parent 5f44cb02
......@@ -269,8 +269,21 @@ There are two configurations for Privacy popup, Default and Media, you can also
## Getting the Device ID
As soon as the SDK starts for the first time, a [Device ID](/service-architecture.md#device-registration-device-ids-and-device-base) is assigned to that specific installation of your app
The SDK provides a way to obtain the Device ID as soon as it is assigned by setting a `IDeviceIdListener`, as shown in the example below.
As soon as the SDK starts for the first time, a [Device ID](/service-architecture.md#device-registration-device-ids-and-device-base) is assigned to that specific installation of your app.
> The Device ID assigned to an installation might change in case of rare events, for example if the local storage of the device gets erased.
The SDK provides two different ways to obtain the Device ID.
### Getting the Device ID through a Device ID listener
The first method to obtain the Device ID is to set a `IDeviceIdListener`, as shown in the example below.
When a listener is set, the SDK immediately returns the Device ID through the `onDeviceIdAvailable()` callback if the Device ID is already available.
Otherwise, it will call the callback method as soon as the ID is obtained.
> The best practice for an app that want to collect on a backend systems the Device ID assigned to each installation, is to set a `IDeviceIdListener` each time it starts.
The mobile app would receive the Device ID each time and should always send it to the backend system.
Then, the backend system should overwrite any previously stored value if the new received value is different.
```java
public class MainActivity extends Activity {
......@@ -298,4 +311,9 @@ public class MainActivity extends Activity {
});
}
}
```
### Getting the Device ID by calling an explicit class method
The second way is to call the `GeoUniq.getDeviceId()` method.
This method returns the value of the Device ID if it has already been obtained or `null` if the Device ID has not been obtained yet.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment