Changing onConnected for Continuous Update
-
0:00 - 0:01这是解决方案。
-
0:01 - 0:04为创建你的 mLocationRequest,只需调用
-
0:04 - 0:09LocationRequest.create,然后设置较高的精度优先级,
-
0:09 - 0:12调用 LocationRequest.setPriority 并向其传递一个常量
-
0:12 - 0:17PRIORITY_HIGH_ACCURACY,可在定位请求类找到此常量。
-
0:17 - 0:21我们已将间隔设为 1000 毫秒,最后,
-
0:21 - 0:26你必须在 FusedLocationApi 上做的所有工作是 requestLocationUpdates 并
-
0:26 - 0:30将其传递到 GoogleApiClient、LocationRequest,
-
0:30 - 0:35这参考本活动,因此回调将到达此活动。
-
0:35 - 0:37所有这些代码应在一条线上,
-
0:37 - 0:40我刚刚将该线分为几条单独的线,以便于读取。
-
0:40 - 0:43现在,因为你要求进行位置更新,
-
0:43 - 0:47所以你将需要实施一个称为 on location changed 的回调,
-
0:47 - 0:52该回调正如其名称所暗示,
每当位置即使改变一点点时将被调用, -
0:52 - 0:55此间隔和此高精度可确定此改变。
![]() |
Udacity Robot edited Chinese, Simplified subtitles for 03-27 Changing onConnected - Solution | |
![]() |
Udacity Robot edited Chinese, Simplified subtitles for 03-27 Changing onConnected - Solution | |
![]() |
Udacity Robot edited Chinese, Simplified subtitles for 03-27 Changing onConnected - Solution | |
![]() |
Udacity Robot edited Chinese, Simplified subtitles for 03-27 Changing onConnected - Solution | |
![]() |
Udacity Robot edited Chinese, Simplified subtitles for 03-27 Changing onConnected - Solution |