Hello, i have some questions about the addProximityAlert function. My task is to develop an android navigation application. The app reads some gps point out of a gpx-file. Thats not really a problem. If the handy is near the point, the app shall notify me this. So i used the addProximityAlert function:
setProximityAlert () { .. double lati = lat[arrayindex]; //the saved gps data double lng = lon[arrayindex]; expiration=-1; .. Intent intent = new Intent(TREASURE_PROXIMITY_ALERT); proximityIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0); lm.addProximityAlert(lati, lng, radius, expiration, proximityIntent); IntentFilter filter = new IntentFilter(TREASURE_PROXIMITY_ALERT); registerReceiver(new ProximityIntentReceiver(), filter); } public class ProximityIntentReceiver extends BroadcastReceiver { public void onReceive (Context context, Intent intent) { String key = LocationManager.KEY_PROXIMITY_ENTERING; entering = intent.getBooleanExtra(key, false); if (entering) arrayindex++; //lm.removeProximityAlert(proximityIntent); } The setProximityAlert () function is called if the position has changed. I develop the app with the emulator and Android SDK 1.5. I use the console with geo fix commands to simulate gps data. If you can see in this lines of code, I use an arrayIndex. I've save all gps data of the gpx file in an array. If the handy is near the first point, the ProximityAlert notify, that the handy enters this position. My problem is, that sometimes the ProximityAlert fires only one time, sometimes 3 times or more. I think the problem is the expiration time? But if I took a value like 2000 (2sec), the proximityAlert only works for 2 seconds?! A solution can be, that I use multiple proximityIntents variables, so that I save all proximityAlerts with addProximityAlert function only once. But if I than enters the position of the third gps point before the second or first point, the ProximityAlert will fire, but it shouldn't before them! What can I do? Must I implement a subactivity, which starts when I entered the first position, than raise a counter and go back into the main activity? I think the problem will be the same? Greets, Stefan PS: I'm german, so apologize some mistakes. And this project is my first in the Android world. So i'm not an expert.. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---