I'm experimenting with proximity alerts, and seeing some odd behavior
when trying it out (on a Nexus One running Android 2.3.4, build GRJ22).

Specifically, once a proximity alert is first set, the GPS icon in the
status bar seems to stay on continually, blinking if it hasn't got a
fix.  Which is what you expect when the proximity alerts are active,
but I still see the icon in the status bar even after the proximity
alerts are removed (so far as I can tell), and even after
uninstalling the app (which, I think, should certainly clear them
--- though if there's a way to get the LocationManager to list active
proximity alerts, that would be useful to know).

Unfortunately, I'm not seeing much enlightening on "adb logcat" ---
in particular, there aren't any backtraces.

The code I'm using to set them is Scala, so it may look a bit odd,
but for these purposes it's pretty nearly Java with less punctuation
(and inferred types on variable declarations).  I've included the most
relevant bits below.  The whole thing in context is here:

  https://github.com/rst/shopping_assistant/tree/reflective_orm

(other files there may be of interest to connoisseurs of experimental
ORM projects), and the relevant bits of

  .../src/main/scala/ProxAlertManagement.scala

follow here:

  def resetProxAlert( shop: Shop, list: ShoppingList ): Unit = {
    if (prefs.getBoolean("enabled", false) &&
        list.undoneItems.count.fetchOnThisThread > 0)
    {
      Log.d( "XXX", "adding prox alert for shop " + shop.id + " at lat " +
            (shop.latitude / 1e6).toString + " long " +
            (shop.longitude / 1e6).toString + " radius " + alertRadiusMeters
)
      locManager.addProximityAlert( shop.latitude / 1e6,
                                    shop.longitude / 1e6,
                                    alertRadiusMeters,
                                    -1,
                                    buildPendingIntent( list, shop ))
    } else {
      deleteProxAlert( shop, list )
    }
  }

  def deleteProxAlert( shop: Shop, list: ShoppingList ): Unit = {
    Log.d( "XXX", "removing prox alert for shop " + shop.id + " at lat " +
          (shop.latitude / 1e6).toString + " long " +
          (shop.longitude / 1e6).toString
          )
    locManager.removeProximityAlert( buildPendingIntent( list, shop ))
  }

  def buildPendingIntent( list: ShoppingList, shop: Shop ) = {
    val intent = new Intent( ctx, classOf[ ProxAlertManagement ] )
    intent.putExtra( shopIdKey, shop.id )
    intent.putExtra( listIdKey, shop.shoppingListId )
    PendingIntent.getBroadcast( ctx, 0, intent,
                                PendingIntent.FLAG_CANCEL_CURRENT )
  }

Thanks in advance for any assistance...

Robert Thau

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to