Jul 3 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 3 | 4:00 PM |
Alexander B. | has entered the room |
Alexander B. |
hi
|
Mark M. |
howdy, Alexander
|
Mark M. |
how can I help you today?
|
Alexander B. |
I am trying to get my database to work on the real device
|
Bruce F. | has entered the room |
Alexander B. |
I was following an example
|
Alexander B. |
but it just doesnt seem to work
|
Mark M. |
um, could you clarify a bit on "doesnt seem to work">
|
Mark M. |
(BTW, howdy, Bruce!)
|
Bruce F. |
Hi Mark.
|
Alexander B. |
ok well i get a null pointer exception
|
Frank S. | has entered the room |
Alexander B. |
it doesnt seem to be able to find the file
|
Alexander B. |
this is the code it uses
|
Mark M. |
what is "the file"?
|
Alexander B. |
View paste
(4 more lines)
|
Mark M. |
(BTW, howdy, Frank!)
|
Frank S. |
hi
|
Mark M. |
that's fairly unpleasant code
|
Alexander B. |
i know
|
Mark M. |
I take it your objective is to package a database with your app -- is that correct?
|
Alexander B. |
yes
|
Alexander B. |
i took that example from a book
|
Mark M. |
I recommend SQLiteAssetHelper: https://github.com/jgilfelt/android-sqlite…
|
Jul 3 | 4:05 PM |
Mark M. |
you will find coverage of this in _The Busy Coder's Guide to Advanced Android Development_, and the 0.8 version of the Omnibus
|
Mark M. |
this would replace all the code you have above, and it has been fairly well tested at this point
|
Alexander B. |
thats great
|
Alexander B. |
thats great
|
Mark M. |
let me take some questions from the others, and I'll come back to you in a bit
|
Mark M. |
Bruce: do you have a question?
|
Alexander B. |
offcourse
|
Bruce F. |
sdk tools rev 20 breaks Sherlock project. Suggestions?
|
Mark M. |
it isn't breaking any of mine -- can you be more specific?
|
Bruce F. |
conflict with support library versioning
|
Bruce F. |
View paste
|
Mark W. | has entered the room |
Mark M. |
then synchronize your projects
|
Mark M. |
either upgrade ABS to use the newer library or downgrade your app to use the older one
|
Mark M. |
R20 does not really care either way, other than perhaps when it initially sets up a new project with the new template stuff
|
Mark M. |
(BTW, howdy, Mark!)
|
Bruce F. |
I upgrade abk how?
|
Mark W. |
hi
|
Bruce F. |
abs that is
|
Mark M. |
copy the android-support-v4.jar into libs/, the same as you would for any other project
|
Mark M. |
it already has one
|
Bruce F. |
thank you
|
Mark M. |
Frank: do you have a question?
|
Frank S. |
View paste
(7 more lines)
|
Tom O. | has entered the room |
Jul 3 | 4:10 PM |
Tom O. |
A hoy hoy
|
Mark M. | |
Mark M. |
(howdy, Tom!)
|
Frank S. |
yes
|
Mark M. |
but your console paste has you in tests/bin
|
Mark M. |
that directory should not exist
|
Mark M. |
you start in directory $FOO
|
Mark M. |
you create your test project in $FOO/ROAMpayX/tests
|
Mark M. |
you change into $FOO/tests
|
Mark M. |
and try running tests from $FOO/tests/bin
|
Mark M. |
admittedly, I am rusty on the test setup process, so maybe I am mis-remembering the android create test-project command
|
Frank S. |
That must be a typo. ROAMpayX is the main project and tests/ gets created correctly inside of that
|
Mark M. |
OK
|
Frank S. |
yeah the -m option is relativly to the test project
|
Mark M. |
does SplashActivityTests actually contain test methods?
|
Frank S. | |
Mark M. |
ah
|
Frank S. |
made sure to use import android.test.suitebuilder.annotation.SmallTest;
|
Mark M. |
Android uses JUnit 3 -- no assertion-based tests
|
Mark M. |
um, OK
|
Mark M. |
I have never seen that syntax
|
Mark M. |
on Android, anyway
|
Mark M. |
try using more classic JUnit test method names, like testDummy(), where the test method starts with "test"
|
Frank S. |
that just gave me the @SmallTest
|
Jul 3 | 4:15 PM |
Mark M. |
I have definitely used tests in a tests/ subdirectory of the main project, so that should not be your problem
|
Frank S. |
Mark your the man.
|
Frank S. |
I didn't even realize. I changed dummyTest to testDummy and it worked!
|
Frank S. |
lol
|
Mark M. |
yeah, names matter, particularly in JUnit 3
|
Mark M. |
JUnit 4 and above have a means of declaring them
via annotations (BTW, typo in earlier chat message where I said
"assertions" rather than "annotations")
|
Mark M. |
anyway, moving along...
|
Mark M. |
Mark: do you have a question?
|
Mark W. |
greeting from China, quick one for you....
|
Mark W. |
looking for approaches to display a sting in a TextView, playing with ViefFlow, ViewPager, etc
|
Ben K. | has entered the room |
Mark W. |
variable length string, and need a way to auto create the view, maybe kind of like the Omnibus book example?
|
Mark M. |
sorry, but I am lost
|
Mark M. |
what is ViefFlow?
|
Mark M. |
(BTW, howdy, Ben!)
|
Ben K. |
Hello
|
Mark W. |
ViewPager needs to create views manually, can I create views automatically based on size of the string?
|
Mark M. |
your PagerAdapter can return whatever you want
|
Mark W. |
for example with cirlceindicator, perhaps I need 5
circles and 5 views is the string is a certain length, is that how the
book reader example works in omnibus?
|
Mark M. |
if it wants to make decisions based on string length, string contents, string theory, or string cheese, it can certainly do so
|
Jul 3 | 4:20 PM |
Mark M. |
I don't know what the "5 circles and 5 views" are referring to
|
Mark W. |
ok, thanks, that helps Mark, cheers.
|
Mark M. |
the book reader knows the number of chapters based on the count included in the JSON
|
Mark M. |
for each page, it creates an appropriate fragment, though they are all the same fragment in the case of EmPubLite
|
Mark M. |
EmPub itself uses different fragments (e.g., a cover page fragment)
|
Mark M. |
Tom: do you have a question?
|
Tom O. |
Yeah, just a quick one I'm sure.
|
Tom O. |
Say I have a service running in the background
(unbound). That services does something of interest to the user. What
is the best way to signal the user that something was done?
|
Mark M. |
that depends
|
Mark M. |
if there's no chance that a foreground activity would care, just use a Notification
|
Tom O. |
Say there might be a foreground activity?
|
Mark M. |
if, however, a foreground activity might want to update the user directly, use an ordered broadcasts
|
Mark M. |
I cover this pattern in The Busy Coder's Guide to Advanced Android Development and v0.8 of the Omnibus
|
Tom O. |
So if the foreground activity isn't running anymore, then what happens to the ordered broadcast?
|
Tom O. |
Ah, cool. I shall go check those out.
|
Mark M. |
a BroadcastReceiver in the manifest picks up the broadcast and raises a Notification
|
Mark M. |
the ordering is so the activity can get in first (via priority) and can abort the broadcast (to avoid the Notification)
|
Mark M. |
the nice thing is that the service neither knows nor cares if there is an activity in the foreground that needs the event
|
Jul 3 | 4:25 PM |
Tom O. |
Yes, that is exactly what I'm trying to avoid - some sort of affinity between my service and an activity.
|
Tom O. |
thanks a bunch!
|
Mark M. |
happy to help
|
Mark M. |
Ben: do you have a question?
|
Ben K. |
Yes
|
Mark M. |
go ahead
|
Ben K. |
It's about an exception so I'm not sure to what
extent can be helped, but I am using a multithreaded DefaultHttpClient,
and on a get I got a socket exception: connection timed out. I was
wondering if you know any obvious gotchas.
|
Mark M. |
:: shrug ::
|
Mark M. |
server might not be running, might not have an Internet connection, etc.
|
Ben K. |
I see. Ok, thanks!
|
Mark M. |
that's probably a better question for the HttpClient folk, to enumerate the possible triggers of a timeout
|
Mark M. |
Alexander: do you have another question?
|
Alexander B. |
yes please
|
Alexander B. |
i am trying to get the value from a customcursoradapter and return it to the main activity
|
Alexander B. |
i can upload the code if it will help
|
Jul 3 | 4:30 PM |
Mark M. |
what is "the value"?
|
Jul 3 | 4:30 PM |
Alexander B. |
the value is an int
|
Mark M. |
um, OK
|
Mark M. |
a custom CursorAdapter is used by an AdapterView, like a ListView
|
Mark M. |
you can call methods like getItem() on the CursorAdapter to get a Cursor positioned on some index
|
Mark M. |
you can then ask that Cursor to retrieve an integer column via getInt(), passing in the index of the column to retrieve
|
Mark M. |
since the custom CursorAdapter is presumably held
by the "main activity", that activity would do this work to retrieve
your desired int
|
Mark M. |
let me take some questions from the others, and we can follow up in a bit if there is time
|
Alexander B. |
would it help if i showed you some of the code
|
Mark M. |
Alexander: to be honest, probably not in this case
|
Mark M. |
Bruce: do you have another question?
|
Bruce F. |
Yew. Very general question - looking to load a
google image into a view. I know it needs to be async. Any other general
guidelines or cut and paste code suggestions before I start?
|
Jul 3 | 4:35 PM |
Mark M. |
if by "google image" you mean some Google Images API, I have never used it
|
Mark M. |
you should ponder your caching strategy, to prevent excessive re-downloads of the same image
|
Bruce F. |
just generally downloading an image off the web
|
Mark M. |
beyond that and the async stuff, I have no general recommendations
|
Bruce F. |
thank you
|
Mark M. |
Frank: do you have another question?
|
Frank S. |
View paste
|
Mark M. |
I would phrase it more as "design it like you would design a REST Web service"
|
Frank S. |
Or Helper class that just modify queries and returns
|
Mark M. |
oh, I see
|
Bruce F. | has left the room |
Mark M. |
I did not realize that Contacts used separate ContentProvider subclasses -- I thought it only used one
|
Mark M. |
hold on...
|
Frank S. |
Yeah. The helper classes would just use the one provider query and customize it for that table
|
Mark M. |
yeah, Contacts has a few providers, but they are more per-database than per-table
|
Mark M. |
for a single database, multiple tables, a single ContentProvider should suffice
|
Frank S. |
Yeah. We aren't going to have nearly as much code and information as the Contacts
|
Mark M. |
you would use portions of the path after the
authority and before the instance ID to identify the table (or virtual
table, after doing some joins and such)
|
Frank S. |
so you saying go the helper class route?
|
Mark M. |
yes
|
Mark M. |
or, if you prefer, extend ContentProvider several times, with a composite ContentProvider at the top level
|
Mark M. |
from a manifest standpoint, I'd only have one ContentProvider and one authority for a database
|
Jul 3 | 4:40 PM |
Frank S. |
Ahh. I see. I actually think I may like that route better.
|
Mark M. |
whether you wish to steal the ContentProvider API to implement a composite pattern is up to you
|
Ben K. | has left the room |
Mark M. |
though it's possible you'll need to create your
own interface that mirrors the ContentProvider API, as you probably
cannot instantiate a ContentProvider directly yourself
|
Mark M. |
Mark: do you have another question?
|
Mark W. |
Yes, occasionally get a VM SHUTTING DOWN after my
app runs a long time, especially if users switch languages a lot of
times- on the fly switcher button. Have been looking at MAT and pretty
sure there are no memory or thread leaks. 2.3, but not using drawables.
Any causes for Dalvik to Shut down suddenly?
|
Mark M. |
not that I am aware of
|
Mark M. |
other than normal Android process termination
|
Mark M. |
from your description, though, I assume that your app is in the foreground when this happens
|
Mark W. |
yes, in the foreground
|
Mark W. |
thanks mark, appreciate this forum.
|
Mark M. |
yeah, that should not happen
|
Mark M. |
sure, though I am stunned you are making use of it right now -- isn't it pretty early in the morning where you are?
|
Mark W. |
right. all nighter.
|
Mark M. |
ah, sorry to hear that
|
Mark M. |
Tom: do you have another question?
|
Jul 3 | 4:45 PM |
Mark M. |
OK...
|
Mark M. |
Alexander: do you have another question, or a follow-up from your last one?
|
Mark M. |
OK, if anyone has any more questions, chime in
|
Jul 3 | 4:50 PM |
Frank S. |
nope. You killed it today Mark, lol
|
Tom O. | has left the room |
Mark W. | has left the room |
Jul 3 | 4:55 PM |
Frank S. |
Thanks Mark. Talk to you Thursday
|
Frank S. |
happy 4th
|
Mark M. |
you too!
|
Jul 3 | 5:00 PM |
Mark M. |
OK, that's a wrap for today's chat
|
Mark M. |
next one is Thursday at 10am
|
Mark M. |
have a pleasant day!
|
Alexander B. | has left the room |
Frank S. | has left the room |
Mark M. | turned off guest access |