在为给定的一组坐标注册接近警报之后
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Intent intent = new Intent(Constants.ACTION_PROXIMITY_ALERT);
intent.putExtra(Constants.INTENT_EXTRA_LOCATION, location); // custom payload
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);
locationManager.addProximityAlert(location.getLatitude(),
location.getLongitude(), location.getRadius(), -1, pendingIntent);当我进入或离开配置的位置时,我会将意图发送到我的服务。到现在为止还好。
不幸的是,这些传递的意图都没有携带标识位置更改类型(进入或退出)的布尔型额外LocationManager.KEY_PROXIMITY_ENTERING,该via可以通过Intent.getBooleanExtra检索。我的观察是基于AOSP 2.1和AOSP 2.2。根据documentation的说法,这个额外的东西应该一直存在。
我是不是错过了什么?当在模拟器上使用模拟位置运行时,对于这个额外的东西有限制吗?
发布于 2011-06-30 02:42:47
事实证明,这似乎是由于在PendingIntent中额外添加了一个可序列化的额外代码造成的。作为一种解决办法,可以自己执行序列化,或者如果需要额外的有效负载,则只存储基元类型或字符串。
https://stackoverflow.com/questions/6507718
复制相似问题