What's the trick to making ProximityAlerts work?

by Faber Fedor » Sun, 08 Mar 2009 08:46:51 GMT


Sponsored Links
 ProximityRadius *is* big.  I think I was using 1500 meters in the field test
today.  The "10 feet" I mentioned below was the minimum distance to travel
before doing an location update. And I mean "10 meters".

I beginning to think my mental model is all wrong.  I thought I could
blindly throw intents out to the Android and it would fire off PAs back at
me.  Which intent belonged to which latlong was my problem to figure out.
I'm now thinking I need to keep each PA intent in a global data
structure^W^W^Winstance variable and carry them around with me and run an
RequestUpdate on each one. :-?

Is there someway for me to monitor myLocationManager to see when he fires
off a PA?







-- 

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 09:17:41 GMT


 


Ah, sorry. FWIW, requestLocationUpdates() and addProximityAlert() should
be orthogonal -- the settings you supply requestLocationUpdates() should
not impact the behavior of addProximityAlert().


PAs? I'm guessing you mean proximity alerts, not Pennsylvanias or
precious armadillos or something.


I don't think so, by design. LocationManager is a system service; your
app does not even need to be running to get a proximity alert.

The first edition of my Android book had a sample app that used
proximity alerts. I dumped that sample app (after having to re-re-write
it due to the constantly-changing location API) and now my book does not
have a proximity alert sample. I'll see if I can work that into _Android
Programming Tutorials_, though.

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

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


Sponsored Links


What's the trick to making ProximityAlerts work?

by Faber Fedor » Sun, 08 Mar 2009 09:27:07 GMT


 




I think there's still some connection between the two that I'm missing.




I noticed. :-)

The only example I've come across is WhereAmI.java which is based on a
previous SDK. I'm trying to glean the solution from that.

 For a "killer feature" of Android, there isn't much discussion or many
examples out there.




Another book?

-- 

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

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



Other Threads

1. Best Practice question: Passing an array to a View

I can't quite see how you're doing MVC here. I see a view, and I see a
Game class which looks a bit like it might be a model? Where's the
controller?

Generally, in MVC, the view registers its interest in the state of the
model via the Observer pattern. Thus, the model has no knowledge of
the view, but simply provides an interface that the view implements
that does the view-specific stuff. Thus, the model would never need to
have any imports related to the view.

You can similarly separate out the platform-specific aspects of the
controller, delegating them to the view. The view handles mapping from
UI-specific event (like, "this button was clicked") to a generic event
which is passed to the controller. Then the only platform-specific
stuff would be any platform-specific stuff the controller might do for
a particular application, if any. (This can then be abstracted out
into a "platform" layer).

Generally, your model does not need to know about either the View or
the Controller (except implicitly via the registered observers). The
controller needs a reference to both the model and the view.

The view doesn't need a reference to the controller, if you make the
controller an observer of the view. Or the view can have a reference
to the controller. I usually end up giving the view a reference to the
controller, as it simplifies initializing different subviews.

As to your second question -- you don't ask a question. You'd like to
do it. You can do it -- and usually should do it. So do it! Are you
wondering how to do it with your own view classes? You can do that,
too, see the examples in the platform SDK, especially the custom views
demo.




-- 

2. Memory Leak

I am using a simple frame animation and when I exit and reenter my
activity the activity is still referenced in memory. Any Ideas?

//This is a sample activity I created to simulate the problem
public class MemoryLeakActivity extends Activity {

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
        public boolean onKeyDown(final int keyCode, final KeyEvent event) {
        final Intent i = new Intent(MemoryLeakActivity.this, LeakyActivy.class);
        startActivity(i);
                return super.onKeyDown(keyCode, event);
        }
}

//This is the activity that runs the frame animation
public class LeakyActivy extends Activity {

        AnimationDrawable frameAnimation;
        
        @Override
        protected void onCreate(final Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                
                setContentView(R.layout.main);
                
                final View v = findViewById(R.id.main);
                
                v.setBackgroundResource(R.drawable.awe);
                
                frameAnimation = (AnimationDrawable) v.getBackground();
                
        }

        @Override
        public boolean onKeyDown(final int keyCode, final KeyEvent event) {
                frameAnimation.start();
                return super.onKeyDown(keyCode, event);
        }

}


If I start LeakyActivity then hit the back button then start
LeakyActivity again it stays in memory. I know this because I have
been dumping the HPROF files.

-- 
Joshua Frank

-- 

3. Spica plus App2sd plus recovery plus wifi tethe

4. Are travelling citizens allowed to develop applications?

5. Android market place crashes on receiving intent for an application that doesn't exists in marketplace

6. Pausing Live Wallpapers

7. Creation of a Developer Wanted / Artist Wanted / Services Offered page?