Office Hours — Today, November 1

Thursday, October 20

Nov 1
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Maria
has entered the room
Mark M.
howdy, Maria
Maria
Good morning.
Mark M.
how can I help you today?
Maria
Mostly I want to just listen today but I do have a question that you may or may not be able to help me with.
Mike
has entered the room
Maria
Hi Mike
Mark M.
howdy, Mike
Mike
Hello, good morning. :)
Mark M.
Maria: go ahead with your question
10:00 AM
MikeToo
has entered the room
Mark M.
howdy, MikeToo
MikeToo
hi all
Mark M.
Maria: do you want to wait on your question?
Maria
I would like your opinion on this. I purchased a cute little app that tracks your movements as you sleep. In particular it uses the accelerometer sensor and also the microphone. The thing that is funny is that the sensor tracking only works if the display is left on (which isn't really conducive to great sleep).
If you turn off the display, all it seems to record is start and end times.
I'm wondering if this would be the behavior
Mark M.
yes, sensors tend to want the device to be awake
Maria
if the app was using an activity
instead of a service
Mark M.
that should not matter
you will need at least a partial WakeLock to get sensor readings
now, my understanding is that some devices require the screen to be actually lit up as well
Maria
would that keep the display light an button lights on?
Mark M.
presumably, this is a power saving thing
yes
well, actually, a partial WakeLock only keeps the CPU on
Maria
CPU makes sense
Mark M.
there are other, stronger WakeLocks that will turn on the screen and optionally the keyboard
Maria
display light/button light doesn't really
Mark M.
a full WakeLock keeps everything on
Maria
ok.
Mark M.
it may be that the developer elected to go full WakeLock for max compatibility
Maria
I see.
Let's let Mike go next.
Mark M.
OK
Mike: do you have a question?
Mike
Yes I do. :)
10:05 AM
Dimitri
has entered the room
Mike
Hi Mark, I have an issue with a listview. I'm using a custom adapter extending array adapter. I'm attempting to add additional data to the bottom of a listview from a json source. Even though the add() call seems correct and the size of the adapter increases, the listview never changes, even if I notify the adapter that the dataset has changed/been invalidated.
Mark M.
howdy, Dimitri
Dimitri
Hi Mark
Mark M.
Mike, your question sounds vaguely familiar... :-)
Mike
Indeed. ;)
(Thanks again for the email discussion, Mark.)
Mark M.
so when you say "the listview never changes", you mean if you scroll to the bottom, your row is not there?
Mike
Correct. I instantiate the adapter, and the first block of 20 rows appears.
When I hit the viewswitcher, it loads the json, calls add on the superclass, adapter size increases, but no changes on screen.
Mark M.
it's conceivable there's something peculiar with your layout that is causing problems
add() should take care of everything
Dimitri
View paste
I have a question for you.

My app start with a splash screen and then show Activity A. Then the user may go to B-C-D-E...

Anytime, the user may show activity Z, which should clear the history stack (Activity Z is the "Dashboard Menu"). I clear the stack to clear the memory.

How would you implement sich mechanism?
Mark M.
Dmitri: hold on, I'm taking questions one at a time -- you're after MikeToo
Dimitri
sure :)
Mike
I was under that impression as well, Mark.
Mark M.
Mike: the link is to one of the book samples showing add() in action
Mike
Thank you. I'll review my layout.
Mark M.
in particular, you might try temporarily simplifying it (e.g., not sure where the ViewSwitcher comes into play) and see if things start behaving better
10:10 AM
Mark M.
it's possible you've tripped over a bug in Android
though, if so, your only tactical option is to find a workaround
Mike
Okay, I'll keep that in mind, thank you Mark.
Mark M.
since it's not like we can fix everybody's copy of the OS :-)
MikeToo: do you have a question?
Mike
:)
MikeToo
Sure, thanks Mark ... I've been playing with StrictMode and testing on real devices, and I'm seeking some guidance on where to draw the line about the violations it reports. Things like "getSharedPreferences()" are reported which seems a bit odd to me
Mark M.
well, getSharedPreferences(), the first time it is called, will read the preferences out of XML
MikeToo
true
Mark M.
while they could give you apply() instead of commit() for saving stuff on a background thread, they didn't provide an async load option
come to think of it, a SharedPreferencesLoader is probably something we need
at least in some cases, anyway
MikeToo
it's not taking tons of time - like 352ms
should I even worry about it
Mark M.
the key with disk I/O is that the load time is highly variable
particularly with Android 2.2 on down and some 2.3 devices that use YAFFS2 for the filesystem
if another application is using the disk, yours will be blocked
some 2.3 devices and everything(?) going forward use ext4 for the filesystem, alleviating this problem
however, issues like how full the flash is have performance impacts, though I think that's more for writes (e.g., wear leveling)
MikeToo
ok, I only write for 2.1+, so I still need to worry about it then
Mark M.
well, "worry" may be overstating it :-)
if it's convenient for you to load it in an AsyncTask, do it
if it's not convenient, I'd wait until you start getting complaints
MikeToo
I can, ok thanks
10:15 AM
Mark M.
the disk I/O StrictMode concerns will be more something to "worry" about for loops or for things like scrolling a ListView
for a one-off gotta-pay-the-piper load of your SharedPreferences, I wouldn't bend over backwards to get it off the main application thread, only if its easy
MikeToo
ok, it was useful in finding a few places like that, I just got puzzled by the sharedPrefs thing
Mark M.
Dmitiri: with respect to your question, add FLAG_ACTIVITY_CLEAR_TOP in the Intent that starts Activity Z
that will remove all other activities from the back stack
Maria: do you have another question?
Dimitri
Mark: FLAG_ACTIVITY_CLEAR_TOP will in fact clear the stack, but only if Z was started before A. :(
Mark M.
then also add FLAG_ACTIVITY_SINGLE_TOP
Maria
I just wondered if it would be feasible to disassemble the application and if I find a fullWakeLock change it to partial and repackage and install. I'm only interested in fixing this on my phone. I would have to use my own self-signed cert and install it as a new application. If doing this is even feasible. Your thoughts?
Mark M.
can you disassemble the app? Yes, if you can get your hands on the APK
10:20 AM
Mark M.
can you change the constant and rebuild it? Presumably, though I have never tried this
Dimitri
FLAG_ACTIVITY_SINGLE_TOP doesn't clear the back history either, only the forward history :(.
So my solution right now is launching Z, but without calling "setContentView()", and calling setContentView() on onResume(), but with a
Mark M.
can you sign and install it using your own key? Yes, but you'd have to uninstall the existing copy first
Maria
It's on the phone but it might be in part of the disk that is not mounted?
Dimitri
... with a boolean :)
Mark M.
Dimitri: then start a new task with FLAG_ACTIVITY_NEW_TASK
Maria: it is definitely not on the mounted portion
you can probably find instructions for pirating APKs off a device via a search engine
Maria
Thanks. At the rate I am getting around to doing anything, this is probably just a thought exercise anyway.
Dimitri
I haven't tought of using FLAG_ACTIVITY_NEW_TASK. I'll give it a try :)
Mark M.
Mike: do you have another question?
Dimitri
Another question: do you plan to update your book before AnDevCon? I plan to print them to read on the plane... :)
Mark M.
Dmitri: I will push out a small update to the Tutorials book to bring it in line with the latest ADT
otherwise, no updates before AnDevCon
in part, because it would appear there will be no Galaxy Nexus before AnDevCon
Mike
Yes, I do have one more while I have you here, Mark. The same app (which I inherited, mind you) saves a "shopping list" of sorts. It does this by storing a blob of json in shared preferences & committing. On some older devices, particularly the LG Ally, this is unworkably slow.
10:25 AM
Mike
This seems related to MikeToo's earlier question. Since IO can be a mess on older devices, any thoughts on how to properly save out this data? Is SharedPrefs not the proper spot for it?
(The app was using the SD card, lots of user complaints about that, apparently.)
Mark M.
I'd use either a database or a plain file with the JSON
no particular value in having it as a SharedPreference
Mike
Did I read that correctly that disk access is blocked using SharedPrefs, if other apps are using the disk?
Mark M.
for devices with a YAFFS2 filesystem, *all* disk I/O is blocked while another app is doing disk I/O
there's a global partition lock
Mike
Ouch. I suspect that may be the case on the Ally.
Mark M.
so all disk I/O is serialized via that lock
the Ally seems to be ill-regarded by the dev community
Maria
Anyway to determine what kind of filesystem a particular device is using?
Mark M.
if it's 2.2 or older, guaranteed to be YAFFS2 pretty much
Mike
I have a bad ESN Ally arriving today via eBay for testing. Apparently generated a lot of complaints from users on that device.
Mark M.
3.0 and newer should be ext4
2.3 is a mixed bag, as I understand it
Mike
Thank you Mark.
Mark M.
MikeToo: do you have another question?
MikeToo
yes, thanks - speaking of the books - do you know if the ePUB format works with the Google Books software? I'm wanting to get them on my Galaxy Tab for reading
Mark M.
no clue
I test with Aldiko
I have no idea if Google Books can read files outside of the ones served by Google
I've never used the app, actually
10:30 AM
MikeToo
ok, it was pre-installed - was just trying to use what I had
Mark M.
ah, OK
sorry, no experience with that particular app and its capabilities
Maria
Aldiko 2 has a very easy import procedure
MikeToo
I'll give that a shot - thanks!
Mark M.
Dimitri: do you have another question?
Maria
Mark, on reading your books. Should I start with the tutorials?
Mark M.
Maria: that depends on how best you learn
if you learn by doing, the Tutorials is a fine starting point
Maria
I also have access to several books by you via Safari books. Is there one there you would recommend as an alternative to starting with tutorials?
Mark M.
I doubt you have access to several of mine through Safari, unless you are counting multiple editions of _Beginning Android_ as the "several"
Maria
yes I was
Mark M.
_Beginning Android_ is the same as _The Busy Coder's Guide to Android Development_
Maria
ok
10:35 AM
Maria
I am good then.
Mark M.
OK, free for all: anyone with a question, chime in
Mike
Last one from me Mark.
You mentioned storing that JSON in a plaintext file, which is fine. Recommendations on where to store it? i.e. Check for media mounted, if so, store it on the SD card?
Mark M.
all else being equal, I'd use internal storage unless you have a reason to do otherwise
if nothing else, it's always there
and this file is (presumably) fairly small
Mike
Yes, that's correct, usually a very small file, few K at most.
Mark M.
yeah, internal storage (e.g., getFilesDir()) should be fine
maybe offer an export or backup feature to copy it on demand to external storage
Mike
Great, thank you so much. I may see you in the next chat, depending on how the rest of the dev goes today. :) Have a good day, everyone!
Maria
Bye Mike
10:40 AM
Mike
has left the room
Dimitri
has left the room
10:45 AM
MikeToo
Aldiko works great - got the books downloaded and installed - thanks for that
Mark M.
EPUB and a reader like Aldiko is the best present answer on Android
PDF works well for references, but PDF viewers often don't keep your place in the book
MOBI and the Kindle app work, but the quality is lower due to MOBI format limitations
MikeToo
I tried the Kindle app, but it has issues if you have not logged in for a while, it won't let you read your books
or if WiFi is not available
Mark M.
"logged in"?
I only had to set up my account once
if you mean that the app hasn't synced with the mother ship in a while, I can see where that might be a problem
MikeToo
well, I don't know - it was frustrating - tried to read a book once, it said I needed to "log in" but I was in a spot without WiFi
10:50 AM
MikeToo
ok, I guess I'm out - thanks for the books, thanks for this chat service, and thanks for the help!! I have more questions, but need to read more before I ask them. Y'all have a good one
Mark M.
see ya!
MikeToo
has left the room
Maria
I don't have any other questions just now, Mark. Thanks for your help.
Mark M.
you're very welcome!
11:00 AM
Mark M.
have a pleasant day!
Maria
has left the room
Mark M.
turned off guest access

Thursday, October 20

 

Office Hours

People in this transcript

  • Dimitri
  • Maria
  • Mark Murphy
  • Mike
  • MikeToo