Proximity alerts problem

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Proximity alerts problem

Postby Draffodx » Tue Mar 31, 2009 1:32 pm

I'm trying to use proximity alerts on my map activity so when someone drives into a car park they know whether they need a disk or to pay for a ticket.

I have the alerts working properly, however when an alert is fired all the other alerts seem to get fired too, so if the user goes into car park 4 the messages for the other car parks get fired too.

here is my code

oncreate
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setProximityAlert(53.984511, -6.395137, "Car Park 1", "You are in a staff/lecturer car park, you must have a valid disk to park here");
  2.  
  3.       setProximityAlert(53.983862, -6.394853, "Car Park 5", "You are in a staff/lecturer car park, you must have a valid disk to park here");
  4.  
  5.       setProximityAlert(53.985969, -6.395288, "Car Park 2", "You are in a paid car park, please ensure you have paid for a valid parking ticket for the time you intend to stay parked");
  6.  
  7.       setProximityAlert(53.986101, -6.394590, "Car Park 3", "You are in a paid car park, please ensure you have paid for a valid parking ticket for the time you intend to stay parked");
  8.  
  9.       setProximityAlert(53.986350, -6.393346, "Car Park 4", "You are in a paid car park, please ensure you have paid for a valid parking ticket for the time you intend to stay parked");
Parsed in 0.032 seconds, using GeSHi 1.0.8.4



setproximityalert()
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void setProximityAlert(double lat, double lng, String title, String text) {
  2.  
  3.      LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  4.  
  5.  
  6.  
  7.     // double lat = 53.984511;
  8.  
  9.     // double lng = -6.395137;
  10.  
  11.      float radius = 30f; //meters
  12.  
  13.      long expiration = -1; //do not expire
  14.  
  15.    
  16.  
  17.      Intent intent = new Intent(TREASURE_PROXIMITY_ALERT);
  18.  
  19.      PendingIntent proximityIntent = PendingIntent.getBroadcast(getApplicationContext(), -1, intent, 0);
  20.  
  21.      locationManager.addProximityAlert(lat, lng, radius, expiration, proximityIntent);
  22.  
  23.      
  24.  
  25.      IntentFilter filter = new IntentFilter(TREASURE_PROXIMITY_ALERT);
  26.  
  27.      registerReceiver(new ProximityIntentReceiver(title, text), filter);
  28.  
  29.    }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4



proximityintentreciever
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class ProximityIntentReceiver extends BroadcastReceiver {      
  2.  
  3.            Game2 game = new Game2();
  4.  
  5.            
  6.  
  7.            String title;
  8.  
  9.            String text2;
  10.  
  11.          
  12.  
  13.           public ProximityIntentReceiver(String title, String text){
  14.  
  15.                    
  16.  
  17.                    this.title = title;
  18.  
  19.                    this.text2 = text;
  20.  
  21.            }
  22.  
  23.          
  24.  
  25.          @Override
  26.  
  27.           public void onReceive (Context context, Intent intent) {
  28.  
  29.             String key = LocationManager.KEY_PROXIMITY_ENTERING;
  30.  
  31.            Log.d("PROXIMITy KEY ENTER", LocationManager.KEY_PROXIMITY_ENTERING);
  32.  
  33.  
  34.  
  35.             Boolean entering = intent.getBooleanExtra(key, false);
  36.  
  37.            Dialog d = new Dialog(Game2.this);
  38.  
  39.         // Have the new window tint and blur the window it
  40.  
  41.         // obscures.
  42.  
  43.         Window window = d.getWindow();
  44.  
  45.         window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
  46.  
  47.         WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
  48.  
  49.         d.setTitle(title);
  50.  
  51.         d.setContentView(R.layout.dialog_view);
  52.  
  53.         TextView text = (TextView)d.findViewById(R.id.dialogTextView);
  54.  
  55.         text.setText(text2);
  56.  
  57.            
  58.  
  59.         d.show();
  60.  
  61.             //[ ... perform proximity alert actions ... ]
  62.  
  63.           }
  64.  
  65.    }
  66.  
  67.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


Can anyone suggest a better way to set up the proximity alerts so that they dont all fire when when proximity is fired? or point out where the mistake is in my code?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Postby Draffodx » Thu Apr 02, 2009 11:19 am

anybody got any ideas?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest