Mark M. | has entered the room |
Mark M. | turned on guest access |
Marcin | has entered the room |
Mark M. |
howdy, Marcin!
|
Mark M. |
how can I help you today?
|
Marcin |
Hi Mark
|
Andrew G. | has entered the room |
tunneling | has entered the room |
Mark M. |
howdy, Andrew and tunneling!
|
Mark M. |
Marcin: do you have a question?
|
tunneling |
howdy howdy
|
Marcin |
yes
|
Andrew G. |
hello
|
Dec 20 | 4:00 PM |
Marcin |
AsyncTask can be cancelled by invoking cancel(boolean) on it
|
Marcin |
and then checking isCancelled during loadInBackground
|
Marcin |
is there a similar mechanism in AsyncTaskLoader?
|
Jan | has entered the room |
Jan |
Hi everyone
|
Mark M. |
there is cancelLoad() that you can call on Loader
|
Mark M. |
(BTW, howdy, Jan -- be with you in a bit)
|
Jan |
ok
|
Dustin R. | has entered the room |
Marcin |
what about cancelLoadInBackground()?
|
Marcin |
how one should use it?
|
Mark M. |
you don't use it
|
Mark M. |
it really should be named onCancelLoadInBackground()
|
Mark M. |
you override if if needed
|
Mark M. |
the default implementation is an empty method
|
Marcin |
if i use cancelLoad() how should I check for it during loadinbacground?
|
Mark M. |
I have not tried cancelLoad() or cancelLoadInBackground(), and so I do not know much more about them, sorry
|
Marcin |
ok, thanks
|
Mark M. |
(BTW, howdy, Dustin!)
|
Marcin |
thats it from me for now
|
Dec 20 | 4:05 PM |
Mark M. |
OK, Andrew got in slightly before tunneling, so...
|
Mark M. |
Andrew: do you have a question?
|
Andrew G. |
Ok quick one first
|
tunneling |
im just hanging out.. so skip me for now
|
Dustin R. |
Hi Mark, I am a huge fan of your books, I am a
former east asian language teacher currently java developer of 3 years
looking to write free langauge learning apps. I hope you dont mind the
overly general question but what chapters would you recommend I focus
on?
|
Andrew G. |
It is generally reccomended that one register a broadcast receiver in onResume and unregister it onPause
|
Mark M. |
um, that *is* pretty general :-)
|
Mark M. |
but, Dustin, I will get to your question in a bit
|
Mark M. |
Andrew: please continue
|
Dustin R. |
ok thank you, take your time ^_^
|
Andrew G. |
How should I handle it if I want to take an action
on my registered receiver accounting for screen sleep (which would
unregister it)
|
Andrew G. |
IIRC wakelocks = bad
|
Mark M. |
can you be a bit more specific about "take an action">
|
Mark M. |
?
|
Andrew G. |
well, I have an inbox which gets push broadcasts from C2DM about new messages
|
Andrew G. |
I want it to show that message
|
Mark M. |
is the message purely within the C2DM/GCM payload, or are you having to do additional I/O?
|
Andrew G. |
all in the payload
|
Andrew G. |
well sorry that's not ture
|
Andrew G. |
true*
|
Andrew G. |
not if I have an attachment
|
Andrew G. |
which I then d/l separately
|
Mark M. |
OK, for the main message, you can just update the
UI, assuming this BroadcastReceiver is registered via the activity by
registerReceiver()
|
Mark M. |
you'd then also use DownloadManager or your own IntentService to download any attachments
|
Mark M. |
and, if it is your own IntentService, probably use WakefulIntentService (or the equivalent) just for the download
|
Dec 20 | 4:10 PM |
Andrew G. |
Can an IntentSerice be killed off randomly as well?
|
Mark M. |
um, define "killed off randomly"
|
Andrew G. |
low device memory (just like Activities)
|
Mark M. |
neither activities nor services are "killed off randomly" due to low memory conditions
|
Mark M. |
*processes* can be terminated to free up memory due to low memory conditions
|
Mark M. |
and, yes, processes containing services can be killed off, though that is less likely
|
Mark M. |
you can use startDownload(), if you feel it is
warranted, during your download to further increase the odds that you'll
be left alone
|
Mark M. |
let me swing through the rest of the group, and I can follow up with you more in a bit
|
Mark M. |
tunneling: do you have a question?
|
Andrew G. |
ok thanks
|
tunneling |
no sir
|
Mark M. |
ah, just hanging out?
|
Mark M. |
no problem
|
Mark M. |
Jan: do you have a question?
|
Jan |
Hi Mark,
|
tunneling |
ya
|
Jan |
Here is my question :
|
Jan |
In your "SQLite Database" chapter at the end you
write about Async CRUD updates. Later on in the "Contentprovider"
chapters you introduce the "new" Loader framework for async queries with
content providers. Is there anything new to insert/update/delete in
async way on a contentprovider, or do we have to use the "traditional
techniques" from the "SQLite Database" chapter using AsyncTask ?
|
Mark M. |
Loader is only for loading
|
Mark M. |
you update a ContentProvider using an AsyncTask or regular Java thread
|
Mark M. |
unless somebody provided utilities to handle that for you
|
Mark M. |
so, for example, my SQLiteLoader offers methods to handle CRUD operations, and handles the threading for you
|
Jan |
OK understood
|
Dec 20 | 4:15 PM |
Mark M. |
but CursorLoader does not, which is why you have to do the async work yourself
|
Dec 20 | 4:15 PM |
Jan |
I'll have a look at the SQLiteLoader, thanks
|
Jan |
Can i ask you another question ?µ
|
Mark M. |
yes, but let me get to everyone first
|
Jan |
ok
|
Mark M. |
Dustin: back to your question
|
Mark M. |
is there something in particular about your apps that you are concerned about vis a vis the book coverage?
|
Dustin R. |
capabilities needed: screen draw non roman characters, save all my data in sql lite database, creating fun UI
|
Dustin R. |
err
|
Dustin R. |
mainly #1
|
Mark M. |
that then boils down to whether or not you have a font with the glyphs you need for the language you want
|
Dustin R. |
screen drawing non roman characters and tehn recognizing them, is there anything you are aware of that does this?
|
Mark M. |
(either the stock font for the device or one you bundle)
|
Mark M. |
oh, wait
|
Mark M. |
when you mean "screen drawing", you mean the *user* drawing them, or *you* drawing them?
|
Dustin R. |
user drawing
|
Mark M. |
oy
|
Mark M. |
the recognition part would presumably fall under OCR, which Android does not natively support, and is a serious resource hog
|
Dustin R. |
I read the legacy titles when they were new but i was curious if there was anything that could support that now days
|
Mark M. |
you might be able to work out a simpler approach, if you are only dealing with individual characters or short strings
|
Mark M. |
(e.g., fuzzy match images)
|
Dustin R. |
yeah that would be another approach
|
Mark M. |
but that too isn't built into Android -- you'd need to find libraries for full-on OCR or fuzzy image matching
|
Mark M. |
with regards to drawing, there's nothing specifically built in for that either
|
Dec 20 | 4:20 PM |
Mark M. |
there are plenty of "sketch" samples out there
|
Mark M. |
and Square had a couple of blog posts about signature capture which might be semi-relevant
|
Mark M. |
doing more in this area is on my to-do list for 2013
|
Dustin R. |
oh great, i look forward to it
|
Mark M. |
assuming that I survive after midnight
|
tunneling |
google "Machine Learning"
|
Mark M. |
tunneling: yeah, that might be part of the mix too, though that is also resource intensive in general
|
Dustin R. |
ah hmm android might not be the best platform for a tool like that
|
Mark M. |
coming up with something that can run on garden-variety phones is going to be a challenge
|
Mark M. |
just due to CPU and RAM constraints
|
Dustin R. |
ok, thank you. i will let you know when i have more specific questions
|
Mark M. |
OK
|
Mark M. |
back to the beginning...
|
Andrew G. |
esp since 'garden-variety' means sad looking Ginerbread phones :P
|
Mark M. |
Marcin: do you have another question?
|
Marcin |
yes
|
Marcin |
View paste
|
Mark M. |
um, beats me
|
Marcin |
"..db and not connect.."
|
Mark M. |
I have never tried using the Loader paradigm for Internet operations
|
Mark M. |
and IMHO it is inappropriate for having it update a database based on loading
|
Marcin |
how would you do it?
|
Mark M. |
a plain AsyncTask or an IntentService
|
Dec 20 | 4:25 PM |
Mark M. |
cancel-ability would have me lean towards AsyncTask
|
Dec 20 | 4:25 PM |
Marcin |
how would you cancel it?
|
Mark M. |
(IntentService tends to better for "fire and forget" approaches)
|
Mark M. |
call cancel()
|
Mark M. |
in your read-the-InputStream loop and such, check to see whether you are cancelled
|
Marcin |
how about db? should i call isCancelled() check before every db operation
|
Mark M. |
possibly
|
Mark M. |
personally, I'd think that if you went to the trouble to download the data, you may as well save it to the database
|
Mark M. |
but, if you're sure that you do not want to do that, check whether you were canceled before running the transaction
|
Marcin |
im with you that since i have the data i should store it
|
Marcin |
but if app is not running how should i leave db connection?
|
Mark M. |
by definition, the app is running
|
Mark M. |
otherwise, your process is gone, your task is gone, etc.
|
Marcin |
at the moment i have a static ref to db
|
Mark M. |
the general strategy in complex apps is to not worry about closing the database
|
Mark M. |
because there's never a good time to do it
|
Marcin |
and i simply dont close it anywhere
|
Mark M. |
and SQLite handles this well
|
Mark M. |
that's what ContentProviders do
|
Mark M. |
so not closing it, if you do not know when to close it, is (unfortunately) reasonable
|
Marcin |
hmm.. i will try this approach.. Thanks Mark, thats it from me for now.
|
Mark M. |
OK
|
Mark M. |
Andrew: do you have a question?
|
Dec 20 | 4:30 PM |
Andrew G. |
I do, about the ViewPager
|
Andrew G. |
I load a bunch of images into it that are
downloaded one by one via IntentService. At the begining I set a
'placeholder' image so the user can flip through all of the images that
*will* be there
|
Andrew G. |
As I'm notified via PendingIntent that the image is ready, I'd like to replace those placeholders
|
Andrew G. |
What I'm finding is that I can't do that reliably
|
Andrew G. |
if the user is viewing a placeholder when I get that callback, it will not be updated via notifyDatasetChanged
|
Mark M. |
why are you using notifyDataSetChanged()?
|
Mark M. |
why not just update the ImageView of the current page?
|
Andrew G. |
I change the drawable in the underlying set
|
Andrew G. |
well, I had tried that and it gives *changes* but just goes blank
|
Andrew G. |
doesn't redraw with new content
|
Mark M. |
if you update the ImageView, I feel pretty darn sure that it will redraw
|
Andrew G. |
ugh well hopefully the problem is not the fact that I'm using a third-party wrapper around ImageView
|
Andrew G. |
GestureImageView to support zoom/pan
|
Mark M. |
hmmm... that's not out of the question
|
Mark M. |
the implementation might have made assumptions about the immutability of the image
|
Andrew G. |
Guess I could switch to vanilla and see if I get the update
|
Mark M. |
you might consider making the placeholder be a
regular ImageView, load your real image into the GestureImageView, and
toggle visibility
|
Dec 20 | 4:35 PM |
Mark M. |
(assuming GestureImageView and replacing the image winds up being the sticking point)
|
Andrew G. |
resource intensive no?
|
Mark M. |
assuming that your placeholder is a resource, it shouldn't be too bad
|
Mark M. |
only one copy of that bitmap will be in memory
|
Andrew G. |
so the ViewPager would be paging through ViewFlippers?
|
Andrew G. |
flipping between the imageView and GestureImageView
|
Mark M. |
ViewFlipper?
|
Mark M. |
no, I meant toggle visibility
|
Mark M. |
setVisibility(View.GONE)
|
Mark M. |
setVisibility(View.VISIBLE)
|
Andrew G. |
isn't the VIewFlipper the proper way to do that?
|
Mark M. |
well, you could, but a FrameLayout works quite nicely too
|
Andrew G. |
alrighty I'll give it a whirl thanks
|
Mark M. |
ViewFlipper would be if you wanted an animated effect, or automatic changes, or something
|
Mark M. |
Jan: do you have a question?
|
Jan |
Yes
|
Mark M. |
(and, tunneling, if you have one at some point, let me know and I'll add you back into the queue)
|
Jan |
What is the best way to have a bidirectional sync
between the local SQLite DB of many mobile android phones with a central
SQL server. I know about the SyncAdapter, but one still has to
implement the sync algorithm himself. Apart from Microsoft Sync
Framework Toolkit, is there any good sample or libary that offers
reliable sync ?
|
tunneling |
k
|
Mark M. |
on the server side, I haven't a clue
|
Mark M. |
I haven't touched Microsoft server products in earnest in over a decade
|
Mark M. |
and the server side will dictate terms for what you do client-side
|
Jan |
What about non-MS products ?
|
Mark M. |
plus, I haven't played with SyncAdapter much yet (on the relatively-early-in-2013 to-do list)
|
tunneling | has left the room |
Mark M. |
bi-directional sync will not be much fun
|
Jan |
Great, looking forward to it, because I cannot imagine I'm the only one with this problem
|
Jan |
Why not ?
|
Mark M. |
my usual solution is to find something that does it for me (e.g., CouchDB)
|
Mark M. |
if there are updates to the same rows on both sides, dealing with merge conflicts may be troublesome
|
Mark M. |
and fairly scenario-dependent
|
Dec 20 | 4:40 PM |
Mark M. |
but, I'm sorry, I'm just not well versed in this area at the moment
|
Jan |
Do you know of any samples with CouchDB ?
|
Mark M. |
specifically with Android, no, though my
understanding is that CouchDB offers sync between the Android edition
and a regular CouchDB server
|
Jan |
I see, no problem ... i wait for Q1/2013 :-)
|
Jan |
I'll have a deeper look in CouchDB in meanwhile. Thanks
|
Mark M. |
obviously, I need to refine my definition of "relatively early"... :-)
|
Mark M. |
Dustin: do you have another question?
|
Dustin R. |
Care for another general one?
|
Mark M. |
sure
|
Dustin R. |
I understand from your book about data passing in
UI's with widgets and all, do you know any tutorials about making them
graphically appealing?
|
Mark M. |
well, everyone has their own definition of "graphically appealing"
|
Mark M. |
at least 90% of which I find unappealing
|
Mark M. |
the guts lie in the styles and themes
|
Mark M. |
but there is little documentation about all the
possible levers that you can pull and switches that you can throw in
terms of styling the stock widgets
|
Mark M. |
let alone the specific mechanics (e.g., what sorts of images need to be created)
|
Mark M. |
there's a variety of blog posts floating around that discuss the topic
|
Mark M. |
but I don't exactly have their URLs at my fingertips
|
Dustin R. |
okay I can google them
|
Dec 20 | 4:45 PM |
Mark M. |
personally, particularly with the holographic
theme that debuted with Android 3.0, I'm fairly happy with the look of
the stock widgets and don't mess with it, except perhaps for styling the
action bar a bit using the Action Bar Generator
|
Dustin R. |
OKay i will look up holographic theme
|
Dustin R. |
that would be really helpful
|
Mark M. |
for simple color changes on widgets, for Android 3.0+, use the Holo Colors Generator: http://android-holo-colors.com/index.php
|
Dustin R. |
and for pre 3.0 devices I will just have to set an older theme?
|
Andrew G. |
!
|
Mark M. |
there is the HoloEverywhere project, which is trying to create a theme and assets that allow Holo to work on older devices
|
Andrew G. |
wish I knew about that last week
|
Mark M. |
(Andrew: subscribe to the newsletter! I mentioned it a few months back)
|
Mark M. |
I have not tried HoloEverywhere, personally, so I cannot vouch for how complete it is or how well it works
|
Dustin R. |
Great I will chekc it out. For some reason people show a lot more interest in apps based off looks not content
|
Andrew G. |
ha. Well I think you should still have both (from a person who may be a future consumer of said app)
|
Mark M. |
Marcin: do you have another question?
|
Marcin |
yes
|
Dec 20 | 4:50 PM |
Marcin |
taking under consideration your skill level, are
you considering (or maybe already have done so) creating and monetizing
some apps?
|
Marcin |
just curious
|
Jan | has left the room |
Mark M. |
I have written some apps under contract
|
Mark M. |
any apps that I would write separately would not be "monetized" in the form of paid apps, in app purchases, ads, etc.
|
Mark M. |
as I am just not a huge fan of those business models
|
Dustin R. |
a true open source believer?
|
Marcin |
do you plan on realising your own apps?
|
Mark M. |
more that I am not a mass-market marketer
|
Marcin |
somewhere soon 2013 maybe?
|
Mark M. |
Marcin: I am not planning on writing an app for the sake of writing an app
|
Mark M. |
I have the book in APK form (and have some improvements to make to that this weekend)
|
Mark M. |
my plans for 2013 may involve apps, but they are ancillary aspects of a larger strategy
|
Mark M. |
which is not exactly fodder for an office hours chat
|
Andrew G. |
May I throw in one last technical question?
|
Marcin |
thanks Mark, all devs that i have met in my
limited experience with Android have this plan of creating/monetizng an
app within a year.. even if they work on contract for someone else
|
Mark M. |
Andrew: go ahead
|
Andrew G. |
I'm looking to enforce full disk encryption on all
devices that install my app. I admit I've not yet checked the book on
this but do you cover PolicyManager in any great depth? The offical
docs are rather confusing.
|
Dec 20 | 4:55 PM |
Mark M. |
I cover the device admin APIs in the book, and I mention the full-disk-encryption bits
|
Dustin R. |
Thank Mark, keep up the good work. I am out to get busy developing
|
Mark M. |
I don't have a sample specifically for full-disk-encryption, though
|
Dustin R. | has left the room |
Andrew G. |
np. Just being able to enforce anything would get me going
|
Andrew G. |
so I should be looking for "Admin API" not "PolicyManager"?
|
Mark M. |
the Device Administration chapter is 1287-1296 in the current edition of the book
|
Mark M. |
the class is DevicePolicyManager, IIRC
|
Andrew G. |
great - thanks
|
Mark M. |
we are running out of time -- any final questions?
|
Andrew G. |
that's all for me
|
Andrew G. |
Hope you both enjoy the upcoming apocolypse
|
Marcin |
im out of questions, Thanks Mark
|
Marcin |
going to get my last supper
|
Andrew G. |
heh
|
Mark M. |
I have this vision of Miracle Max from _The Princess Bride_ saying "have fun! enjoy the apocalypse!"
|
Mark M. |
:)
|
Marcin |
hah
|
Marcin |
night night guys
|
Andrew G. | has left the room |
Marcin | has left the room |
Mark M. | turned off guest access |