2010-05-09 60 views
2

我希望我的应用程序有一个proximityAlert,直到用户删除它。我使用过期-1来创建proximityAlert。 proximityAlert 的作品。但是我在我的Droid手机上找到了,在添加了proximityAlert 并且让手机过夜充电后,proximityAlert在第二天不能工作 。除非用户删除它,否则我怎样才能确保我的proximityAlert无限期地活动为 ?AddProximityAlert消失虽然过期-1

回答

1

接近警报使用一个长变量来过期。您是否将proximityAlert中的数字-1或声明为等于-1的long的变量?也许使用一个长变量而不是-1会解决它。

addProximityAlert(双纬度,经度双,浮子半径,长到期,的PendingIntent意图)

1

的LocationManager使用HashMap<PendingIntent,ProximityAlert>来存储他们的警报。
请参阅代码here

1)ProximityAlert使用您提供的PendingIntent作为密钥 如果您为2个坐标添加2个ProximityAlert,但使用相同的PendingIntent,则只有最后一个Proximity警报有效。

2)removeProximityAlert(PendingIntent pIntent)必须用于删除警报。