问题出在标题中.如果应用程序被用户杀死,新的Android Geofences是否会被删除?
我正在使用新的Android Geofences(在Google IO 2013上宣布).如果用户使用Android任务管理器删除/杀死应用程序,那么如果应用程序的Geofences被删除,我就无法解决问题.我认为使用旧的addProximityAlert技术它们并没有被删除.
我在android应用程序中实现了Geofence.我按照这个链接在app中实现了'Geofence'.我正在使用'Retrofit'库来调用'HTTP'请求.
应用具有以下权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Run Code Online (Sandbox Code Playgroud)
这是我的'IntentService'代码:
public class GeofenceService extends IntentService
{
private static final String TAG = GeofenceService.class.getName();
public static final int GEOFENCE_NOTIFICATION_ID = 0;
public GeofenceService() {
super(TAG);
}
@Override
protected void onHandleIntent(Intent intent) {
// Retrieve the Geofencing intent
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
createLoggerFile();
// Handling errors
if ( geofencingEvent.hasError() ) {
String errorMsg = getErrorString(geofencingEvent.getErrorCode() ); …Run Code Online (Sandbox Code Playgroud) 系统是持久存在还是我必须在重启后再次添加它们?我在https://developer.android.com/training/location/geofencing.html的文档中没有找到任何相关信息.
我正在iOS中进行地理围栏.我实际上想在地图上设置不同的区域,每个区域的半径不同.
我实际上想知道iOS地理围栏中区域的最小和最大半径.
谢谢,
我正在尝试使用后台服务为监视器创建地理围栏.地理围栏创建成功并在应用程序活动打开时工作,但在关闭应用程序地理围栏时不起作用.我现在应该怎么做.我的代码是:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
ref = FirebaseDatabase.getInstance().getReference("MyLocation");
geoFire = new GeoFire(ref);
mVerticalSeekBar = (VerticalSeekBar)findViewById(R.id.verticalSeekBar);
setUpdateLocation();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case MY_PERMISSION_REQUEST_CODE:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { …Run Code Online (Sandbox Code Playgroud) 我想在折线周围绘制一个多边形.在我的情况下,折线是Google地图方向,我需要在Google地图画布中围绕它展示多边形.
第一:
对于抵消,我使用JavaScript Clipper Library.我有以下折线(路线):我使用Clipper在下面创建一个偏移多边形:
我有一个有效的JS Bin示例.
代码是:
<html>
<head>
<title>Javascript Clipper Library / Offset polyline</title>
<script src="clipper.js"></script>
<script>
function draw() {
var polygons = [[{"X":72,"Y":59.45},{"X":136,"Y":66},{"X":170,"Y":99},{"X":171,"Y":114},{"X":183,"Y":125},{"X":218,"Y":144},{"X":218,"Y":165},{"X":226,"Y":193},{"X":254,"Y":195},{"X":283,"Y":195},{"X":292,"Y":202},{"X":325,"Y":213},{"X":341,"Y":234},{"X":397,"Y":245},{"X":417,"Y":248}]];
var scale = 100;
reverse_copy(polygons);
polygons = scaleup(polygons, scale);
var cpr = new ClipperLib.Clipper();
var delta = 25;
var joinType = ClipperLib.JoinType.jtRound;
var miterLimit = 2;
var AutoFix = true;
var svg, offsetted_polygon,
cont = document.getElementById('svgcontainer');
offsetted_polygon = cpr.OffsetPolygons(polygons, delta * scale, joinType, miterLimit, AutoFix);
//console.log(JSON.stringify(offsetted_polygon));
// Draw red offset polygon
svg …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google Play服务中的geofencing api,但我无法设法让我的广播接收器触发其onReceive()方法.
看起来我尊重使其工作所需的一切,但我没有过渡事件.
ACCESS_FINE_LOCATION许可BroadcastReceiver在我的Manifest中注册了我的导出值设置为"true"(有人说它是必需的)ACCESS_MOCK_LOCATION存在延迟)但是,我仍然获得了成功的onAddGeofencesResult()回调,但没有onReceive()回调.我尝试使用Nexus 5和Nexus 7,两者都无法触发地理围栏过渡.
我还尝试了https://developer.android.com/training/location/geofencing.html上的示例,但其行为完全相同.
这是我的BroadcastReceiver班级:
public class GeofencesReceiver extends BroadcastReceiver implements ConnectionCallbacks, OnConnectionFailedListener, OnAddGeofencesResultListener {
private final static String TAG = "GeofencesReceiver";
private Context context = null;
private LocationClient locationClient = null;
/**
* An empty constructor is needed by the manifest.
*/
@SuppressWarnings("unused")
public GeofencesReceiver(){}
public GeofencesReceiver(Context context){
this.context = …Run Code Online (Sandbox Code Playgroud) android broadcastreceiver geofencing google-play-services location-client
一切都正确构建并在模拟器中运行,但我似乎无法让我的IntentService记录任何东西.我确信有一些我缺少或忽视的基本内容,但我对Android/Java很新,并且此时已经没有想法了.
public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private Geofence geofence;
private PendingIntent mGeofencePendingIntent;
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LatLng latLng = new LatLng(39.7492350, -104.9913250);
geofence = new Geofence.Builder()
.setRequestId(GEOFENCE_REQ_ID)
.setCircularRegion(latLng.latitude, latLng.longitude, GEOFENCE_RADIUS_IN_METERS)
.setExpirationDuration(GEOFENCE_EXPIRATION)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
}
private boolean checkPermission() {
Log.i(TAG, "MainActivity.checkPermission()");
return (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED);
}
private GeofencingRequest getGeofencingRequest() {
Log.i(TAG, "MainActivity.getGeofencingRequest()");
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER); …Run Code Online (Sandbox Code Playgroud) 我需要根据用户与特定位置的接近程度以及其他一些规则(如果该区域有任何特定消息)向用户发送特定消息.例如,用户上车并开始工作.当他到达工作岗位的那一刻,他会得到某种消息,如果有消息要传递的话.这就是我的想法(当我在我的应用程序的其他部分工作时,没有代码只是试图设计流程)
收听重要的位置更改,每次发生这种情况时,都会将用户的地理位置发送到服务器,以查看是否有任何消息要在该位置附近发送.不行.由于过度使用收音机,这会耗费太多电池.
每天保存消息区域,并在每个重要位置更改对本地存储的数据进行测试.如果有任何匹配那么联系服务器.理论上听起来更好.
问题:
百万感谢任何花时间清理这些东西的人.
编辑:额外问题7.区域监测,添加了大量区域对系统有任何影响?说有2个地区对100个地区?
geofencing ×10
android ×7
geolocation ×2
google-maps ×2
ios ×2
java ×2
geofire ×1
gps ×1
http ×1
iphone ×1
javascript ×1