psaltamontes wrote:
> I have put to the end of the onCreate function the code to add the
> proximity alert:
>
> myLocationManager.addProximityAlert(LATITUDE_ALERT,
> LONGITUDE_ALERT, RADIUS_ALERT, EXPIRATION_ALERT, new
> Intent(this,alertClass.class));
<snip>
> [ alertClass is a simple Activity that shows a screen with a text. ]
I have not used addProximityAlert() with a component-based Intent (i.e.,
using a Class in the constructor), or one that launches a new Activity.
I have only used it with a String-based Intent (i.e., one using a String
in the constructor) designed to trigger an intent receiver I have
registered via registerReceiver().
Here's a few lines of code from the TourIt sample of my book, which I
really really really really hope will be ready for you by next Monday:
protected static final String PROXIMITY_ALERT = new
String("com.commonsware.tourit.intent.action.PROXIMITY_ALERT");
protected final IntentFilter proximitylocationIntentFilter = new
IntentFilter(PROXIMITY_ALERT);
private ProximityIntentReceiver receiver=new ProximityIntentReceiver();
registerReceiver(receiver, proximitylocationIntentFilter);
Intent i=new Intent(PROXIMITY_ALERT);
myLocationManager.addProximityAlert(pt.getLatitude(),
pt.getLongitude(),
100.0f,
43200000,
i); // 12 hours max
> Into exit function I remove the proximity alert, this is the code of
> exit function:
>
> private boolean exit() {
> //remove proximity alert
> myLocationManager.removeProximityAlert(new
> Intent(this,alertClass.class));
>
> this.finish();
> return true;
> }
That might not work. You aren't removing the alert with the same Intent
as you used for registering it. You are using an *equivalent* Intent
(same contents) but not the same object (i.e., == will fail). Unless the
Android folk say otherwise, I would recommend you hold onto the Intent
you register the alert under and then remove it using the same Intent
object.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training on the Ranch in September! http://www.bignerdranch.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---