本篇文档介绍如何安装和初始化 SDK。
1. 安装 SDK
SDK 的安装方式有两种,你可以任选其一:
<dependency> <groupId>com.wilddog.location</groupId> <artifactId>wilddog-location-android</artifactId> <version>0.1.0</version> </dependency>
|
在build.gradle中添加:
dependencies { compile 'com.wilddog.location:wilddog-location-android:0.1.0' }
|
2. 初始化 Location SDK
初始化需要有高德的 API Key,以及野狗 AppID:
1. 引入高德 API
在build.gradle
中,引入:
compile 'com.amap.api:map2d:latest.integration'
|
2. 初始化 WilddogLocation 服务:
WilddogLocation SDK 依赖于 Wilddog Sync,所以也可以先初始化 Sync 的 App,再用 Sync App 的 Reference 来创建 WilddogLocation 服务:
// 初始化 WilddogOptions options = new WilddogOptions.Builder().setSyncUrl("https://<wilddog appId>.wilddogio.com").build(); WilddogApp.initializeApp(this, options); SyncReference ref = WilddogSync.getInstance().getReference(); WilddogLocation location = new WilddogLocation(ref);
|