Garmin Connect Mobile SDK For Android BLE/ADB

  • A+

Adding the Mobile SDK to a project

The Mobile SDK is distributed separately from the Connect IQ SDK but can be found on the same download page. Inside the zip is a connectiq.jar file along with a sample project to help demonstrate the capabilities of the SDK. To begin using the Mobile SDK in your own project, copy the connectiq.jar file into the libs folder of your Android project.

Additional Requirements

In order for your companion application to communicate with a Connect IQ device the user must also install Garmin Connect Mobile onto their phone. All communication for companion applications running on Android goes through a Garmin Connect Mobile service to reach the device. When initializing the SDK with a wireless connection type this requirement is checked and initialization will fail if Garmin Connect Mobile is not installed. If true is passed to the auto UI parameter of initialize, a message is displayed to the user that they need to either install or upgrade Garmin Connect Mobile and provides them a way to go directly to the application in the Google Play Store. See Displaying a UI message automatically when initialization fails for more information.

Interacting with the SDK

All interactions between the companion application and the Connect IQ application are done via the ConnectIQ class. To use this class you must first obtain an instance of the class and then initialize it.

ConnectIQ connectIQ = ConnectIQ.getInstance(ConnectIQ.IQConnectType.<protocol>);

ConnectIQ.IQConnectType provides two options:

  • WIRELESS - For communicating with the Connect IQ simulator or real device via BLE. This is the default.
  • TETHERED - For communicating with the Connect IQ simulator over the Android Debug Bridge.

Initializing the SDK

Initializing the SDK is an asynchronous process and requires a ConnectIQListener to handle returned states of the SDK. You must wait for the onSdkReady() call to be made before calling any additional API methods. Doing so beforehand will result in an InvalidStateException.

 

connectIQ.initialize(context, true, new ConnectIQListener() {

// Called when the SDK has been successfully initialized

@Override

public void onSdkReady() {

// Do any post initialization setup.

}

// Called when the SDK has been shut down

@Override

public void onSdkShutDown() {

// Take care of any post shutdown requirements

}

// Called when initialization fails.

@Override

public void onInitializationError(IQSdkErrorStatus status) {

// A failure has occurred during initialization. Inspect

// the IQSdkErrorStatus value for more information regarding

// the failure.

}

});

更多内容见开发包中的“MobileSDK1-2.html”。

注意:同一个APP可以控制多个设备,但同一个设备不能被多个APP控制。

文件下载

广告也精彩
  • 微信:Mingtel
  • 微信二维码名片
  • weinxin
  • 支付宝搜索:512000173
  • 充值可抵扣,最多领38元!
  • weinxin
明
佳明开发者 | www.garmindev.cn

发表评论

您必须才能发表评论!

目前评论:11   其中:访客  11   博主  0

    • 沫镧 沫镧 0

      找到组织的感觉

        • SG.明 SG.明 7

          @沫镧 :grin:

            • Handy Handy 1

              @SG.明 环境都配置好了,run as 后白板是怎么回事儿?

                • SG.明 SG.明 7

                  @Handy 控制台输出什么错误?

                    • Handy Handy 1

                      @SG.明 可以正常展示了,莫名其妙,感觉之前一直在连接什么,对了,run as 的时候需要连接garmin的服务器么?应该没有吧?

                      • SG.明 SG.明 7

                        @Handy 没有~

                        • Handy Handy 1

                          @SG.明 感谢!

                  • 4klover 4klover 7

                    支持

                    • 4klover 4klover 7

                      garmin开发平台,

                      • 873903421@qq.com 873903421@qq.com 5

                        下来看看

                        • hotfor1984 hotfor1984 4

                          说的真好,就是没看懂