java - 我需要有关 Android 上的 Geofence 或 Geofire 的帮助
问题描述
每当我的设备进入地理围栏时,我希望根据场景sendNotificationsToEveryone()
触发或触发。sendNotificationsToEveryoneExit()
这是我的代码的函数触发部分:
geoQueryArray[geoFireCount] = geoFire.queryAtLocation(new GeoLocation(geofirelocations.latitude, geofirelocations.longitude), 0.1f);
geoQueryArray[geoFireCount].addGeoQueryEventListener(new GeoQueryEventListener() {
@Override
public void onKeyEntered(String key, GeoLocation location) {
sendNotificationsToEveryone(fcm_tokens_list, geoName);
}
@Override
public void onKeyExited(String key) {
sendNotificationsToEveryoneExit(fcm_tokens_list,geoName);
}
@Override
public void onKeyMoved(String key, GeoLocation location) {
Log.d("MOVE", String.format("%s move within the dangerous area [%f/%f]", key, location.latitude, location.longitude));
//sendNotificationsExit(fcm_tokens_list);
}
@Override
public void onGeoQueryReady() {
}
@Override
public void onGeoQueryError(DatabaseError error) {
Log.d("ERROR", ""+error);
}
});
geoFireCount++;
这是我的设备代码,当它进入地理围栏时,它应该触发 sendNotifications 函数:
final double latitude = Double.parseDouble(part1);
final double longitude = Double.parseDouble(part2);
geoFire1.setLocation("You", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
if (mCurrent != null)
mCurrent.remove();
BitmapDescriptor deviceIcon = BitmapDescriptorFactory.fromResource(R.drawable.watchdevice);
mCurrent = mMap.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.title("GPS Device").icon(deviceIcon));
LatLng coordinate = new LatLng(latitude, longitude);
CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 12);
mMap.animateCamera(yourLocation);
}
});
此代码在同一个文件中,我想知道如何编辑geoQueryArray[]
以包含设备,当它进入地理围栏时,sendNotications
功能将被触发。
解决方案
推荐阅读
- sharepoint-online - JSOM:get_isSiteAdmin() 不区分网站集的用户和管理员
- python - Redhat python 跟踪
- codenameone - 即使我从 Eclipse Marketplace 安装了 6.0 版,也安装了代号 1.0 版
- mysql - mysqldump 命令显示空白
- java - 如何在产品有折扣元素更改时获取 Selenium 文本
- html - 如何更改日历的背景颜色?
- javascript - 防止 Firefox 使用 javascript 处理按键
- apache-spark - python - 如何在带有Python的Spark中使用批处理间隔为10秒的套接字文本流从静态文件中读取?
- reactjs - 无法执行 React 状态更新 - useEffect 问题 - React Native
- asp.net - AddIdentity 的替代品是什么
()..AddActiveDirectoryStores().AddDefaultTokenProviders();