hello, i am developing a navigation software. I read some gps points out of a gpx file. Now i want to know, if i am near a gps point (for example 50m). So i use the addProximityAlert function. My problem is the order. I start with the first gps point, so i only want to know, if i am near the first point. after i am near this point i want to check, if i am near this point and so on. And after i was near the first point, i want to delete this from the proximityAlert function. My code:
after i have read the gps points, i start the setProximityAlert function the first time: private void setProximityAlert() { if(arrayindex!=lat_w.length) { lati = lat_w[arrayindex]; lng = lon_w[arrayindex]; intent.putExtra("pos", arrayindex); proximityIntent = PendingIntent.getBroadcast (getApplicationContext(), arrayindex, intent, 0); lm.addProximityAlert(lati, lng, radius, expiration, proximityIntent); IntentFilter filter = new IntentFilter (TREASURE_PROXIMITY_ALERT); registerReceiver(new ProximityIntentReceiver(), filter); } else Toast.makeText(getBaseContext(), "End of Tour :)", Toast.LENGTH_SHORT).show(); } /** 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); int pos = intent.getIntExtra("pos", 0); Toast.makeText(NavTrack.this, "Treasure: " + entering + " Position" + String.valueOf(pos), Toast.LENGTH_LONG).show(); //only the next gps point!!! if (entering && old_pos+1 == pos) { old_pos=pos; arrayindex++; //for the setProximityAlert function Toast.makeText(getBaseContext(), "Arrayindex: "+String.valueOf(arrayindex), Toast.LENGTH_LONG).show(); lm.removeProximityAlert(proximityIntent); //hmmm, it seems, this doesnt work (because the toast // above shows several time position 0 or 1 or 2 and so on) // Because of that the workaround with if(... old_pos+1..) setProximityAlert (); //set the next gps point from file to addProximityAlert } } I think this is a very dirty code. The best way would be, if i could use a for-loop where i set all proximityAlerts and than check if i am near the first point, after that the second point and so on... So is this possible and does the removeProximityAlert do the right job (delete the proximity alerts for the checked gps point)??? Thanks, Stefan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---