Android LocationServices - 如何测试 onConnectionSuspended 回调

Android LocationServices - how to test onConnectionSuspended callback

我在 Android 上使用 Google 播放服务位置 API,我正在尝试弄清楚如何测试 onConnectionSuspended(int cause) 回调,它是GoogleApiClient.ConnectionCallbacks.

我试过关闭 WiFi、GPS 等,但无法触发此回调。我正在测试的设备没有蜂窝服务提供商,所以我认为关闭这两个服务提供商会起作用...

有没有人有什么想法?

谢谢

selected answer here 描述了如何simulate/test 断开与 Google Play 服务的连接。重要的是断开与播放服务的连接,而不一定是与互联网断开连接——正如您在测试中假设的那样。希望这对您有所帮助!