我们在某些岛屿上分发我们的应用程序时遇到一些问题,我们需要使我们的应用程序能够在“世界其他地区”中使用。
但我们需要确切地知道用户可以在哪里使用该应用程序。
我没有找到“世界其他地区”中定义的国家/地区列表。
有人有这个清单吗?
我尝试在用户到达定义的区域时向其显示推送警报。
所以我从以下网址对我的应用进行了编码:https : //developer.android.com/training/location/geofencing
如果我的应用程序按照用户的位置运行并带有服务,则运行良好。
例如,如果我启动google map,它也可以工作,它也可以跟踪我的位置。推送将出现。
但是,如果我关闭我的应用程序,则不会出现该推送,因此如果没有应用程序在跟踪我的位置,则不会检测到地理围栏。
正常吗?如何使其始终有效?如果需要在您所在的位置跟随前台服务,地理围栏的目的是什么?
public void createGeofenceAlerts(LatLng latLng, int radius) {
final Geofence enter = buildGeofence(ID_ENTER, latLng, radius, Geofence.GEOFENCE_TRANSITION_ENTER);
final Geofence exit = buildGeofence(ID_EXIT, latLng, radius, Geofence.GEOFENCE_TRANSITION_EXIT);
final Geofence dwell = buildGeofence(ID_DWELL, latLng, radius, Geofence.GEOFENCE_TRANSITION_DWELL);
GeofencingRequest request = new GeofencingRequest.Builder()
.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER)
.addGeofence(enter)
.addGeofence(exit)
.addGeofence(dwell)
.build();
fencingClient.addGeofences(request, getGeofencePendingIntent()).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Timber.i("succes");
Toast.makeText(mContext, "Geofence added", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Timber.e(e,"failure"); …Run Code Online (Sandbox Code Playgroud)