Hi,
I have a problem with the proximityAlert function. I develop a
navigation software, which reads some gps data out of a gpx file.
Then I write the first gps point in the addProximityAlert function.
When I get near this point, I want to raise an index to get the next
position from the gpx file (I save all positions in an array). But
some times the ProximityAlert fires one time (fine!), but sometimes it
fires 3 times or more? I think thats a problem with the expiration
time. I choose -1 (never expire). But if I took a value like 2000 (2
seconds), the alert fire only, if i reach the position in the next 2
seconds?
I have try to use the removeProximityAlert function (I have a global
PendingIntent variable therefore).
But then it fires instead of 3 times 6 times?!
I have also test to use multiple PendingInten variables and add them
all with the addProximityAlert function. But then the ProximityAlert
of the third point can fire before the first or second point?!
Here is a part of my code:

private void setProximityAlert() { //will call every time the
location changed

double lati = lat[arrayindex];
double lng = lon[arrayindex];
float radius = 10000f; //meters
long expiration = -1; //-1 für "not expire"

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);
}

/** Proximity Alert Broadcast Receiver */
public class ProximityIntentReceiver extends BroadcastReceiver
{
@Override
public void onReceive (Context context, Intent intent) {
String key = LocationManager.KEY_PROXIMITY_ENTERING;
entering = intent.getBooleanExtra(key, false);
if (entering)
arrayindex++;
entering = false;
//lm.removeProximityAlert(proximityIntent);
}
}

I hope that I discribe my problem well enough. I'm german, so
apologize some mistakes with the english syntax.

Greets,
Stefan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to