1.5 locationListener and ProximityAlert

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

1.5 locationListener and ProximityAlert

Postby nick_wa » Wed Mar 24, 2010 5:24 pm

Have an issue wherein I am using 1.5 and when using the emulator, locationListener onLocationChange will never fire. The listener works fine in the car but I need it to work on emulator with ddms for testing. Right now, with the fix I did, it listens but kills my proximity alerts. To fix the problem (and what kills my proximityalerts) I changed timezone and did the following:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public void onLocationChanged(Location loc) {
  3.  
  4.             if (loc != null) {
  5.  
  6.                 GeoPoint p = new GeoPoint((int) (loc.getLatitude() * 1E6),(int) (loc.getLongitude() * 1E6));
  7.  
  8.                 mapController.animateTo(p);
  9.  
  10.                 mapController.setZoom(17);
  11.  
  12.                 mapView.invalidate();
  13.  
  14.                 locationManager.removeUpdates(locationListener);
  15.  
  16.                 locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,3000,10,locationListener);
  17.  
  18.             }
  19.  
  20.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Problem seems to be that when I have the last two lines, although listener works good, my ProximityAlerts don't fire anymore.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. //the initial call is made here by..
  3.  
  4. setProximityAlert(currentRid.latdst, currentRid.longdst, 17);
  5.  
  6. IntentFilter intentFilter = new IntentFilter(proximityIntentAction);
  7.  
  8. nicksProx=new ProximityAlert();
  9.  
  10. registerReceiver(nicksProx, intentFilter);
  11.  
  12.  
  13.  
  14. private void setProximityAlert(double lat, double lon, int requestCode){
  15.  
  16.             float radius = 50f;
  17.  
  18.             long expiration = 600000;
  19.  
  20.             Intent intent = new Intent(proximityIntentAction);
  21.  
  22.             pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
  23.  
  24.             locationManager.addProximityAlert(lat, lon, radius, expiration, pendingIntent);
  25.  
  26.     }
  27.  
  28.  
  29.  
  30.  
  31.  
  32. public class ProximityAlert extends BroadcastReceiver{
  33.  
  34.                 @Override
  35.  
  36.                 public void onReceive(Context context, Intent intent){
  37.  
  38. locationManager.removeProximityAlert(pendingIntent);
  39.  
  40.                         unregisterReceiver(nicksProx);
  41.  
  42.                         if (more){
  43.  
  44.                                 setProximityAlert(currentRid.latdst, currentRid.longdst, 17);
  45.  
  46.                                 IntentFilter intentFilter = new IntentFilter(proximityIntentAction);
  47.  
  48.                                 nicksProx=new ProximityAlert();
  49.  
  50.                                 registerReceiver(nicksProx, intentFilter);
  51.  
  52.                         }
  53.  
  54.                   }
  55.  
  56. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
nick_wa
Junior Developer
Junior Developer
 
Posts: 15
Joined: Tue Mar 09, 2010 9:51 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests