2013-02-03 33 views
2

我在將多個接近警報添加到我的位置偵聽器時遇到問題。我已經搜索了互聯網,但沒有發現任何幫助。請讓我知道如果我做錯了什麼事情。這裏是我的代碼片斷將多個接近警報添加到位置管理器

locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); 
    locationManager.addProximityAlert(30.0, 70.0, 1000, -1, PendingIntent.getActivity(Map.this, 0, new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.google.com")), 0)); 

    locationManager.addProximityAlert(40.0, 50.0, 1000, -1, PendingIntent.getActivity(Map.this, 10, new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.google.com")),0)); 

從我的仿真器控制時,我給30.0和70.0沒有發生,但是當我給40.0和50.0待處理的意圖觸發。我想將這兩個位置都添加到我的位置經理的近距離警報中

回答

2

您應該使用BroadcastReceiverBroadcastMessages來管理更多的一個近似警報。當您添加第二個警報40.0, 50.0時,您會覆蓋第一個警報。 一個好的解決方案是here

+0

非常感謝你:-) –