use*_*442 1 location geolocation latitude-longitude geofencing android-geofence
我正在尝试 Google 的地理围栏示例项目。我正确获取进入/退出事件。但我怎样才能从中获取用户的当前位置。我想即使在进入/退出点之后也能跟踪用户位置。请帮忙。示例项目来自开发者门户。
在您的广播接收器或服务中,您会得到一个 GeofencingEvent ,用它来获取触发位置
public class GeofenceTransitionsIntentService extends IntentService {
//[...]
@Override
protected void onHandleIntent(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent.hasError()) {
// ...
}
Location l = geofencingEvent.getTriggeringLocation()
}
//[...]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2873 次 |
| 最近记录: |