Feb 8 | 7:55 PM |
Mark M. | has entered the room |
Feb 8 | 7:55 PM |
Mark M. | turned on guest access |
Feb 8 | 8:05 PM |
Julius | has entered the room |
Mark M. |
howdy, Julius!
|
Julius |
hi Mark
|
Mark M. |
how can I help you today?
|
Julius |
(well I will be seeing you hopefully - lucky up got up at 545am yesterday and captured the URL as I started getting 503w)
|
Feb 8 | 8:10 PM |
Mark M. |
yeah, that was quite the fiasco
|
Julius |
I have a concurrent write database issue
|
Julius |
I have a long running task which downloads information from a service provider in batches and then populates a local database
|
Julius |
this takes quite some time as there's a fair amount of information.
|
Julius |
at the same time a user can download a file and some state gets written to the database
|
Julius |
if I get two writes I get a database is locked error
|
Mark M. |
correct
|
Julius |
I can catch this, but unfortunately the state in the views is no longer good for the user
|
Julius |
I was just wondering if you had any advice... (I hope that made some sense)
|
Mark M. |
don't do concurrent writes
|
Julius |
heheh
|
Julius |
:)
|
Mark M. |
either make your "long running task" an IntentService and have the "some state gets written to the database" be handled by it
|
Julius |
is there any way I can queue up database transactions?
|
Mark M. |
or use Java synchronization mechanisms
|
Mark M. |
the IntentService gives you a queue
|
Mark M. |
or use a LinkedBlockingQueue from java.util.concurrent, along with your own thread to monitor it
|
Julius |
ah it is an IntentService so maybe I need to merge these operations (sounds like what you're saying)
|
Mark M. |
it's one solution
|
Julius |
that sounds very smart - actually goes back to something you mentioned to me once before
|
Feb 8 | 8:15 PM |
Julius |
btw - when you say the IntentService gives a queue, is that because it's all in one thread?
|
Mark M. |
plus, there's a queu
|
Mark M. |
er, queue
|
Mark M. |
every onStartCommand() pops the Intent onto the queue
|
Mark M. |
the background thread kicks off
|
Mark M. |
grabs first Intent off the queue, and calls onHandleIntent()
|
Mark M. |
when done with that Intent, sees if anything else is on the queue
|
Mark M. |
if yes, lather, rinse, repeat
|
Mark M. |
if no, stopSelf() and shut down the thread
|
Mark M. |
It's using the queue mechanism inside of a Looper
|
Julius |
ah ok... wow thanks for that - I had no idea.
|
Mark M. |
it's actually a fairly short class
|
Julius |
hmmm so the downside for the user is that if the sync process is happening the download will have to wait
|
Mark M. |
the download doesn't have to wait
|
Mark M. |
updating the database has to wait
|
Mark M. |
it's up to you whether those two operations are tightly coupled or not
|
Julius |
oh I see so maybe I handle the database operations separately...?
|
Julius |
That could work
|
Julius |
it's only temporary
|
Mark M. |
I meant do the download separately from the database operations
|
Mark M. |
if that's possible for your app
|
Feb 8 | 8:20 PM |
Julius |
oh yes
|
Julius |
what I meant but expressed correctly.
|
Julius |
no
|
Julius |
not expressed
|
Julius |
ok thank you very much
|
Julius |
well I'd booked tickets and hotel so thank
goodness I managed to save the state of my registration in a URL which I
later put into a browser 3 hours later - so I hope to see you so you
can put a face to the name
|
Julius |
and I can thank you in person!
|
Julius |
oh I have one other questions
|
Julius |
question
|
Mark M. |
bear in mind that there's a zillion people attending I|O
|
Julius |
(yeah I'll be brief :))
|
Mark M. |
it's actually a bit tough to run into somebody
|
Julius |
well I'll do my best
|
Julius |
being in NZ it's unlikely I'll get to meet people again.
|
Julius |
so
|
Julius |
I have had a few projects come up where people mention using tools like PhoneGap
|
Julius |
this build for multiple platforms - iPhone, BB, android etc
|
Mark M. |
yup
|
Julius |
build => builds
|
Julius |
have you any experience with this - know any pros / cons?
|
Julius |
for my own part it could create some competition but I'd like to know whether I should be learning these tools
|
Julius |
(as if Java and Android isn't enough)
|
Feb 8 | 8:25 PM |
Mark M. |
PhoneGap is covered partially in _Android Beyond
Java_, and that chapter is moving to _The Busy Coder's Guide to Android
Development_ in the next release
|
Mark M. |
I have not used it anywhere but Android, though
|
Julius |
oh oops I didn't see that
|
Julius |
I'll go take a look
|
Julius |
thank you
|
Mark M. |
of all the alternative application frameworks, it's my favorite
|
Mark M. |
however, it assumes you're decent with HTML/CSS/JS
|
Julius |
yeah not exactly my area
|
Mark M. |
particularly AJAX-style, the whole-app-is-a-page sort of app
|
Julius |
there was one I tried using something called lua but the apk was massive fro memory
|
Julius |
thanks for your time.
|
Mark M. |
that too is covered in _Android Beyond Java_, in the NDK chapters, that will eventually move to _Tuning Android Applications_
|
Mark M. |
Lua is not designed for full Android apps
|
Mark M. |
more of a scripting language, kinda like how it is used in WoW and such
|
Feb 8 | 8:30 PM |
Julius |
hi again - just noticed that there's a
<<TBD>> under the Using PhoneGap section and the following
headings are empty. (just downloaded from your site).
|
Julius |
Not a problem for me
|
Julius |
I'm just getting a feeling for it so that was brilliant to read.
|
Mark M. |
that book is a work in progress
|
Mark M. |
or was, anyway]
|
Julius |
ah right no worries
|
Julius |
:)
|
Mark M. |
that chapter will be completed for the next edition of _The Busy Coder's Guide to Android Development_
|
Julius |
ok I'll leave you in peace - thank you very much for the help - that database issue was starting to creep into my sleep!
|
Julius |
bfn
|
Mark M. |
see ya!
|
Julius | has left the room |