What's the trick to making ProximityAlerts work?

by Faber Fedor » Sun, 08 Mar 2009 08:14:04 GMT


Sponsored Links
 I think I'm doing everything right wrt ProximityAlerts but I only get
notified in about 1 in a 100 times.

When I switch to Map Mode in my app, I gt a list of locations, map them and
send each one as a ProximityAlert via this code:

                  Intent intent = new Intent(TYW_PROXIMITY_ALERT);
                  PendingIntent proximityIntent =
PendingIntent.getBroadcast(MainMap.this, 1000, intent, 0) ;
                  myLocationManager.addProximityAlert(dLat, dLong,
proximityRadius, 100000000, proximityIntent);
                  Log.i(TAG, "Added ProximityIntent for" + ""+dLat +","+
""+dLong);

I have an IntentReceiver setup like this:

   public class ProximityIntentReceiver extends BroadcastReceiver {

        @Override
        public void onReceive (Context context, Intent intent) {

            String intentAction = intent.getAction();
            Toast.makeText(MainMap.this,
                    intentAction.toString(),
                    Toast.LENGTH_SHORT).show();
           // stuff about Vibrators and Notifications elided
           }
        }

I set up an IntentFilter programmatically:

    private void setIntentFilters() {
        IntentFilter proxFilter = new IntentFilter(TYW_PROXIMITY_ALERT);
        registerReceiver(new ProximityIntentReceiver(), proxFilter);
    }

which I call in onCreate().

I've set the minimum distance/time to check for updates to be ridiculously
low (10 feet, 5 secs, 0 for each, etc.).

I assumed I didn't actually have to move to see a ProximityAlert fired but
maybe I do, so today I set up three PAs and walked right past the
locations.  The GPS followed right along but I never got a Notification.

What's the magic to get it to work?  Or does it work in some manner I don't
yet grok?


-- 

Faber Fedor
Linux New Jersey
 http://linuxnj.com 
faberfedor.blogspot.com

--~--~---------~--~----~------------~-------~--~----~



What's the trick to making ProximityAlerts work?

by Mark Murphy » Sun, 08 Mar 2009 08:29:20 GMT


 


That may be your problem.

You want proximityRadius to be *big*, not small. A 10-foot proximity
radius means you need to be within 10 feet of the target location before
you will get an alert.

Also, FWIW, the radius is in meters.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android Training in Sweden --  http://www.sotrium.com/training.php 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Copy protection & License key management

1. When the "copy protection" checkbox was first introduced on Android
Market, I heard about a lot of issues with people not being able to
download etc. Have those issues been resolved now? If I turn on copy-
protection on an app with over 10K active users, do I risk a major
rebellion?

2. I'd like to sell my app on other stores like slideme, andappstore
and handango. Since some of these just redirect the user to your own
site to download the app, there needs to be a license key that
authenticates the user and unlocks his app. I saw that andappstore has
a framework for that (not sure if that will only work with them or is
a generic solution). I'm looking for a free, generic licensing
solution. Is there one that you know of or use?  My concern is to not
throw in a wrench in the process of user download and use of the app,
where I start getting a ton of emails from people whose keys arent
working or asking for new keys etc, where license support turns into a
full-time activity.

Any thoughts, experience or pointers on this, specific to Android
apps, would be appreciated.

Thanks
Jay
--~--~---------~--~----~------------~-------~--~----~

2. How to retrieve invalid region during View.onDraw()?

Subject pretty much says it all.  I can't find a getInvalidRegion() or
getInvalidRect() function, or anything of similar intention.  How do I
trim my drawing work during onDraw() to only the invalid region so I
don't bother drawing parts of the view that don't need to be updated?

Thanks.

--~--~---------~--~----~------------~-------~--~----~

3. How to retrieve invalid region during View.onDraw()?

4. Will Google allow this app?

5. ATTN MODERATORS: [ERR] Cupcake version 1.5 to firmware update on phone

6. Very cool and high quality iPhone developer videos

7. Using Widget.TextView.ListSeparator