Office Hours — Today, March 16

Thursday, March 11

Mar 16
7:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
8:00 PM
Prasanna P.
has entered the room
Mark M.
hello!
Prasanna P.
Hi!
View paste
- what is the bettor method to use to see if a bunch of coordinates are within a certain distance from the current location.
1. have a service that requests locations updates from a location manager and checks to see if the new location is close to any of the desired location points.
2. call addProximityAlert() on the LocationManager for each of the locations.  Will this take too much of resources.
Mark M.
addProximityAlert(), most likely
Done right, you do not need to leave any components of your application running
NetApex
has entered the room
Mark M.
they'll just get woken up when you get near something
8:05 PM
Mark M.
howdy, Sir Net, of the house of Apex!
NetApex
Good evening Mr M
Prasanna P.
What do you mean by done right?
Mark M.
if you want to take advantage of not needing any components running, you need to shut down those components :-)
NetApex
Quick question for you. (Not sure if it is a quick answer) I have buttons and ImageButtons and the like. What do I need to do to make it obvious that those buttons are selected?
Svetlin S.
has entered the room
Mark M.
NetApex: define "selected"
howdy, Svetlin!
Svetlin S.
Hi to all.
NetApex
Lol, ok now I feel silly. Thank you!
8:10 PM
NetApex
I should probably look up the way to highlight an item in an xml file
as in "onSelected"
(if there is such a creature)
Mark M.
buttons should already look different when they are selected (i.e., navigated to with the D-pad)
Prasanna P.
OK. Say I call addProximityAlert() from an activity. Then can i close the Activity if the user is not using the activity. Then when you come close to the location will the activity start again?
Mark M.
Prasanna: Android will execute the PendingIntent you supply in addProximityAlert)(
er, make that ()
what that PendingIntent does is up to you
Prasanna P.
OH. OK. Thanks.
Another Question. - I want to have my service call a utility method that returns the distance when I provide it with two geo coordinates. Do I need to have this method in the same class as the service? Or can I create another class that has all of the utility methods and get the service to call a utility method in this other class?
Mark M.
either way works
all depends on how you define your classes
that's a Java/OO thing, nothing particular to Android
NetApex
When I do an "ImageButton btn=(ImageButton)findViewById(R.id.musicIcon);" I can run the D-pad all around the screen to any of the buttons and there isn't a change. Do I have to give it a background or some sorts to make a difference?
Prasanna P.
OK. The service is always running in the background. So does this make any difference in this context?
Mark M.
The service darned well better not be "always running in the background"
Prasanna P.
OK : )
8:15 PM
Mark M.
that's the point I was trying to bring up with the addProximityAlert()
you don't want to try having everlasting services
addProximityAlert() may mean you do not have to
Prasanna P.
OK. Got it. Thanks!
NetApex
(this is why I love listening in.. gives me so many ideas... that I have no clue how to implement)
Svetlin S.
OK, I see no updates, may I ask something?
Mark M.
go ahead
Svetlin S.
I am trying to call asynchronously a web service, but have a problem.
I am using a wrapper of HttpClient, but I think my problem is more generic.
Here it is described in much detail.
8:20 PM
Mark M.
uh, OK
for a small bit of code, this is awfully complicated
first, get rid of theThingHandler
onPostExecute() is invoked on the main application thread, so do your UI updates there
well, actually
I frankly have no idea what's going on in your code
I don't own Unlocking Android, nor have I ever seen HTTPRequestHelper
Svetlin S.
I thought having the handler "forces" the http call to complete?
Mark M.
heck no
the HTTP request has nothing to do with handlers, at least not normally
that is how one of my book examples does a background HTTP request-and-parse
it uses AsyncTask, but no HTTPRequestHelper
Svetlin S.
The Helper is just a convenience wrapper to the default HttpClient.
Mark M.
if nothing else, it may give you some ideas of how Unlocking Android's stuff is supposed to work
OK
HttpClient is already pretty convenient, IMHO :-)
Svetlin S.
But, doesn't registering a handler to HttpClient
Mark M.
HttpClient does not know about Handlers
Svetlin S.
make HttpClient call it as soon as it completes the request?
Mark M.
HttpClient is an Apache project, not an Android thing
8:25 PM
Mark M.
hence, HttpClient *can't* know about Handlers
that's something HTTPRequestHelper must be doing
but, if you're using AsyncTask, you don't *also* need a Handler
anything the Handler would do for you, AsyncTask can
Svetlin S.
Yes, you are correct here.
Interestingly, if I start the Helper in a thread of it's own -- it works.
However, I want to have a background thread for both the HTTPRequestHelper and it's "associated" handler...
which I can call on the main UI thread.
This simplifies my logic.
Mark M.
I'll take your word for that
Svetlin S.
OK. So your advice would be to study the link you posted, I guess.
Mark M.
well, I'm certainly limited in my ability to help with HTTPRequestHelper
I can help with my examples, and I can help with general Android questions
perhaps the Unlocking Android authors have a forum or other place where you can get assistance for HTTPRequestHelper
Prasanna P.
Can I ask a question?
Svetlin S.
Of course, Mark. I asked here as I value your experience in threading.
8:30 PM
Svetlin S.
Thank you for your feedback, it is appreciated!
Mark M.
Svetlin: sorry I can't be of greater assistance
Prasanna: go ahead
Prasanna P.
What is a method you can use to create a dialog from a service where the user has to click to get rid of?
Is this a good idea?
Mark M.
not really
you don't know what the user is doing
if they are playing a game, or in the middle of a text message, they will be...unhappy if you pop up a dialog
that's what Notifications (status bar icons) are for
Prasanna P.
OK. But if i wanted to can I do this?
Mark M.
I don't think so
best you could do is pop up a Dialog-themed Activity
leastways, I have never seen code to pop up a Dialog from a Service
Prasanna P.
OK. Thanks. Need to rethink my approach.
8:35 PM
Prasanna P.
By the way is the reason for this that until the user gets rid of the dialog, the service also will be running and this is not a good idea
because it is resource intensive?
Mark M.
services take up RAM, possibly CPU if they are doing things
moreover, services will be killed off eventually, which is why you don't want to design around an assumption that they live forever
Prasanna P.
Thanks for you help Mark. I am going help out. Buy all.
Mark M.
see you later!
Prasanna P.
sorry i mean I am going to head out.
Prasanna P.
has left the room
8:40 PM
Mark M.
any other questions?
Svetlin S.
No questions, I have enough to think about now... OK, have a nice one everyone, I am off too!
Mark M.
see you around!
Svetlin S.
has left the room
8:45 PM
Sebastian
has entered the room
Mark M.
howdy, Sebastian!
Sebastian
hey there
Mark M.
got any questions?
Sebastian
i have a vague question about the alarmmanager. it seems like i have problems with alarms not firing on a google nexus one
at least so far i have not been able to reproduce it on a different device
isn't there anything which could cause alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, alarmSender); not to cause an alarm?
Mark M.
if somebody hit your app with Advanced Task Killer or the like, that wipes out alarms
Sebastian
like wakelock, time changes maybe ? or deep sleep mode of the device?
Mark M.
WakeLocks should not affect alarm firing
not sure what happens if there's a time change right around the alarm's time
I'm not aware that Android has a "deep sleep mode"
8:50 PM
Mark M.
at least as I would define the term
Sebastian
from what i observed usually things work out on time changes/date changes/time zone changes
Mark M.
how long are you going between alarms? or how far in the future are the alarms that you schedule that aren't firing?
Sebastian
so far i have seen the problem in one hour intervalls
Mark M.
In the code fragment you have above, you used set() instead of setRepeating()
Do you mean your code calls set() for one hour in the future, and then it does not get woken up?
Sebastian
related, can i increase the logcat buffer ? often when i get the log it doesn't go far enough back
Mark M.
I'm pretty sure the logcat buffer size is baked in firmware
you might be able to tweak it for the emulator
Sebastian
yes, i call set for one hour in the future. and call it again to "reschedule"
Mark M.
how frequently does it fail? every alarm, one in 10, one in 100?
Sebastian
i have seen the one hour alarm work and then suddenly stop until the user opens my app and does something which usually set the alarm again
8:55 PM
Mark M.
and, where are you rescheduling it -- inside the onReceive() call of your BroadcastReceiver, or somewhere else?
8:55 PM
Sebastian
usually (with no user interaction) within the onreceive call
Mark M.
hmmm...ok, so you're not going to be falling asleep before the reschedule...
any reason why you're not using setRepeating()?
Sebastian
the intervall might change. e.g. going from one hour to 15min. or to a time 8 hours from now.
Mark M.
oh
Sebastian
so when onreceive is called we reevaluate when to set the next timer.
Mark M.
well, if you can create a sample project that demonstrates the problem, I can look at the code, try it out, see if I see something
and, if it seems like it's a bug in the N1/Android 2.1, we'll need that project anyway to attach to an issue on b.android.com
Sebastian
okay, that's a good idea. maybe i can also eliminate any complexities. very possible that this is caused by some complexities in my app
Mark M.
just remind me that we chatted about this here when you send me the project (or link to the project), either on the [cw-android] Google Group or directly
9:00 PM
Sebastian
okay sounds good. thank you
Mark M.
and that's all the time we have for this evening's chat
next one is Thursday morning (US Eastern time)
have a pleasant evening, all!
Sebastian
bye, good night
NetApex
you too
NetApex
has left the room
Sebastian
has left the room
Mark M.
turned off guest access

Thursday, March 11

 

Office Hours

People in this transcript

  • Mark Murphy
  • NetApex
  • Prasanna Perera
  • Sebastian
  • Svetlin Stanchev