如何删除接近警报?

时间:2017-03-12 01:00:20

标签: android proximity

我有以下

locationManager.addProximityAlert(latitude,
                    longitude,
                    radius,
                    -1,
                    pendingIntent);

如何删除近距离警报?

现在,你可能会说“使用removeProximityAlert”,但为了做到这一点,我认为我需要用于创建警报的待定意图。如果活动保持在最前沿并且永远不会被破坏,我可以轻松地做到这一点,但如果活动被破坏怎么办?

情况如下:我有我的应用程序,设置我想要的纬度和经度,然后添加接近警报。然后我正在进行的火车移动或我必须让我的座位给一位老太太,平板电脑被移动改变方向 - 这使得活动被破坏并再次创建 - 现在我想删除警报。我该怎么办?

1 个答案:

答案 0 :(得分:0)

致电locationManager.removeProximityAlert(pendingIntent)https://developer.android.com/reference/android/location/LocationManager.html#removeProximityAlert(android.app.PendingIntent)

应该以与用于调用locationManager.addProximityAlert(...)的待处理意图相同的额外内容相同的方式创建待定意图