Skip to content

Create Entity Client

To use search or other features, EntityService needs to be initialized and an EntityClient instance needs to be created. The initialize() method will only need to be called once.

Create Cloud Client

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
try {
    SDKOptions sdkOptions = SDKOptions.builder()
            .setApiKey("#API_KEY_PROVIDED_BY_TELENAV#")
            .setApiSecret("#API_SECRET_PROVIDED_BY_TELENAV#")
            .setCloudEndPoint("#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#")
            .setLocale(Locale.EN_US)
            .build();

    EntityService.initialize(sdkOptions);
} catch (EntityException e) {
    // SDK init error, check your API key/secret, cloud endpoint and lib dependencies
}
EntityClient entityClient = EntityService.getClient();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
try {
    val sdkOptions = SDKOptions.builder()
            .setApiKey("#API_KEY_PROVIDED_BY_TELENAV#")
            .setApiSecret("#API_SECRET_PROVIDED_BY_TELENAV#")
            .setCloudEndPoint("#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#")
            .setLocale(Locale.EN_US)
            .build()
    EntityService.initialize(sdkOptions)
} catch (e: EntityException) {
    // SDK init error, check your API key/secret, cloud endpoint and lib dependencies
}
var entityClient = EntityService.getClient()

Create Hybrid Client

Note

If you're using edge or hybrid SDK as listed below, make sure to download SDK data released by Telenav, unzip it and copy it to the path of sdkDataDir.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
try {
    SDKOptions sdkOptions = SDKOptions.builder()
            .setApiKey("#API_KEY_PROVIDED_BY_TELENAV#")
            .setApiSecret("#API_SECRET_PROVIDED_BY_TELENAV#")
            .setCloudEndPoint("#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#")
            .setSdkDataDir("#SDK_DATA_DIR#")
            .setSdkCacheDataDir("#SDK_CACHE_DATA_DIR#")
            .setLocale(Locale.EN_US)
            .build();

    EntityService.initialize(sdkOptions);
} catch (EntityException e) {
    // SDK init error, check your API key/secret, cloud endpoint and lib dependencies
    // Check the existence of local index data or check if the index or cache folder has read/write permissions

}
EntityClient entityClient = EntityService.getClient();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
try {
    val sdkOptions = SDKOptions.builder()
            .setApiKey("#API_KEY_PROVIDED_BY_TELENAV#")
            .setApiSecret("#API_SECRET_PROVIDED_BY_TELENAV#")
            .setCloudEndPoint("#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#")
            .setSdkDataDir("#SDK_DATA_DIR#")
            .setSdkCacheDataDir("#SDK_CACHE_DATA_DIR#")
            .setLocale(Locale.EN_US)
            .build()
    EntityService.initialize(sdkOptions)
} catch (e: EntityException) {
    // SDK init error, check your API key/secret, cloud endpoint and lib dependencies
    // Check the existence of local index data or check if the index or cache folder has read/write permissions
}
var entityClient = EntityService.getClient()

Create Edge Client

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
try {
    SDKOptions sdkOptions = SDKOptions.builder()
            .setSdkDataDir("#SDK_DATA_DIR#")
            .setSdkCacheDataDir("#SDK_CACHE_DATA_DIR#")
            .setLocale(Locale.EN_US)
            .build();

    EntityService.initialize(sdkOptions);
} catch (EntityException e) {
    // SDK init error, check you lib dependencies, the existence of local index data or check if the index or cache folder has read/write permissions
}
EntityClient entityClient = EntityService.getClient();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try {
    val sdkOptions = SDKOptions.builder()
            .setSdkDataDir("#SDK_DATA_DIR#")
            .setSdkCacheDataDir("#SDK_CACHE_DATA_DIR#")
            .setLocale(Locale.EN_US)
            .build()
    EntityService.initialize(sdkOptions)
} catch (e: EntityException) {
    // SDK init error, check you lib dependencies, the existence of local index data or check if the index or cache folder has read/write permissions
}
var entityClient = EntityService.getClient()


The SDK is now ready to use!