我正在尝试创建一个应用程序,其中目标服务在后台运行并通过网络提供商获取用户的位置,当用户靠近其目的地(电话呼叫门)时,它启动另一个针对特定登机口的IntentService,并通过gps提供商更频繁地获取位置更新 问题是,当我尝试将位置放在更活跃的意图服务上时,它根本没有响应。
这是我的onStartCommand中的代码:
Bundle gateData = intent.getExtras();
gateLat = gateData.getDouble("latitude");
gateLong = gateData.getDouble("longitude");
gateName = gateData.getString("gateName");
gatePhoneNumber = gateData.getString("gatePhoneNumber");
gateId = gateData.getInt("gateId");
Log.i("Active onStartCommand for:", gateId+"\n"+gateName+"\n phone:"+gatePhoneNumber);
helper = new MyGatesOpenHelper(this);
currentGate = helper.getGate(gateId);
currentGate.setMode(Gate.MODE_ONHOLD);
helper.updateGate(currentGate);
results = new float[3];
aManager = (LocationManager)getSystemService(LOCATION_SERVICE);
aListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
makeUseOfNewLocation(location);
Log.i("onLocationChanged coords","Lat:"+location.getLatitude()+" Long:"+location.getLongitude());
}
};
boolean isGpsEnabled = aManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
Log.i("GPS Status:",isGpsEnabled?"Enabled":"Disabled");
aManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, aListener);
return super.onStartCommand(intent, flags, startId);