Office Hours — Today, April 26

Tuesday, April 24

Mark M.
has entered the room
Mark M.
turned on guest access
Bruce F.
has entered the room
Mark M.
howdy, Bruce!
how can I help you today?
Bruce F.
From Omnibus 0.5: ((StaticFragmentsDemoActivity)getActivity()).showOther(v);
how does getActivity know which activity to return, if there is more than one?
Mark M.
a fragment instance is only hosted by one activity
Bruce F.
And hello to you too.
Mark M.
just as a widget is only hosted by one activity
Apr 26
7:30 PM
Mark M.
so, getActivity() returns the activity instance that is hosting this fragment instance
Bruce F.
How is the activity showing that it is the host, by referencing the main.xml that contains the fragment?
Mark M.
an activity hosts a fragment either by using a layout with a <fragment> element, or by executing a FragmentTransaction that adds one
Bruce F.
thank you
Mark M.
you're welcome!
Bruce F.
One more...
7:35 PM
Guille
has entered the room
Mark M.
howdy, Guille!
Guille
Hey Mark
Bruce F.
When I run ActionBarDemo in 4.03, with the actionbarsherlock library (which works on everything else I've tried), I don't show the tool icons on the bottom, just the textview and edittext
Mark M.
press the MENU button
Chris
has entered the room
Mark M.
your emulator is probably set up to emulate a device that has a MENU button
which means the ... is suppressed
Bruce F.
thanks
Mark M.
(BTW, howdy, Chris!)
Guille: do you have a question?
Chris
Hey. I'm back after like a 9 month break. I've forgotten everything :)
Guille
View paste
yep writing it out now
Chris
My question is probably horrible and hard to give an exact answer. I'm just looking for general direction. I'm working on a simple app that is going to have a user pressing a button, a REST call being made and the UI updated based on the results of the REST call. I have a mock up where where I create a helper class that sets up the http client and kicks off an AsyncTask to perform the REST call and updates the UI. I want to eventually get it where I can create some sort of helper object that lets me perform http puts, gets, etc on a url and provides me the results. Based on this, I wanted to see if you had a recommendation on what approach I should take. I'm aware of threads, AsyncTask, Handler and Binder.
Mark M.
(Guille: sorry, will get to you after Chris, I guess)
Guille
no problem :)
7:40 PM
Mark M.
Chris: if your request needs to happen regardless of what the user does at the UI layer, have the request be processed by an IntentService, so it runs independently of your activities
otherwise, an AsyncTask is my preferred choice
Chris
Oh yeah I forgot about IntentService
I'll look into that. Thanks.
Mark M.
Guille: your turn now, honest
Guille
I have a question about a situation i had and want some validation on what i found. I was noticing that the Total size of my app was growing on my phone every time i updated a row in my database. What I noticed was that i wasn't closing the database connection on some occasions. would that make the total size of my app grow? closing the connection seems to have fixed it. btw, by size i mean the Total in MB not the Application or Data.
Mark M.
since nothing is cached in SQLiteDatabase (as far as we know), I would find that somewhat surprising
View paste
did you use DDMS and MAT to check for what was consuming the memory?
Guille
nope, but only because I dont know how to :)
Mark M.
oh, wait
are you referring to RAM or on-flash storage size?
Guille
it is possible, i am referring to the size that you see when you look the app on Settings -> Application -> <Application>
Mark M.
that would be on-flash storage
7:45 PM
Mark M.
SQLite is transactional, so I would not expect holding a SQLiteDatabase open to keep any files around that would get cleaned up once you close it
however, that gets into SQLite's own implementation, and I'm far from expert on that
Guille
cool, oh well it seems to be working now, so i guess cross my fingers! :)
Mark M.
Bruce: do you have another question?
Bruce F.
no thank you
Mark M.
OK, if anyone has a question, chime in
Guille
ok I have another one
Mark M.
go ahead
Guille
back to database stuff. this error has only happened once. unfortunately for me it happened to my client
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView
This happened while installing the app on the phone
Mark M.
that's impossible
none of your code runs while installing the app on the phone
Guille
ok maybe I need to get more details then
hmm let me describe the process might give a better idea
Mark M.
that error could certainly occur when the user ran your app
Guille
So maybe it happened right after install and when it was starting
because the first page is a list of companies
Mark M.
one cause would be because you did a requery() on a Cursor from a background thread, where that Cursor was attached to a ListView via a CursorAdapter
7:50 PM
Guille
I am using a custom SimpleCursorAdaptor but i dont requery() anywhere
Mark M.
something in a background thread tried doing something that caused the SimpleCursorAdapter to think data changed
Guille
Yeah, when the user opens the app, onCreate it call a IntentService to update the database. But no where do I try to update the screen with the new data.
Mark M.
:: shrug ::
beats me, then
Guille
jajaja
ok thanks for your help!
Mark M.
you're welcome!
if anyone has a question, chime in
Bruce F.
Running your 0.5 code, I've gotten a couple of strange xml errors, because they reference things that aren't in the xml. For example, with editor.xml in ViewPagerFragmentActivity, I'm getting a failure to resolve a color value in textColor, when there is no text in the xml.
Mark M.
textColor is not set in editor.xml
nor is it modified within EditorFragment
hence, I have no idea what you are seeing
can you take a screenshot?
7:55 PM
Mark M.
(one that shows the error message and location?)
Bruce F.
View paste
I know. But the error I'm getting in the Graphical Layout is"error!
Unable to resolve color value "C:\Users\Bruce\Desktop\library\res\color\abs__primary_text_holo_light.xml" in attribute "textColor"
Mark M.
BTW, I am assuming this is a compile-time error
ah, that's in ActionBarSherlock
make sure your build target for the project is API Level 14 or higher
Bruce F.
<uses-sdk android:minSdkVersion="15" />
Mark M.
no, your build target
Project > Properties > Android
Bruce F.
Android 4.0.3 is the only one checked
actionbarsherlock works fine elsewhere
Mark M.
well, that should be fine
try Project > Clean and see if that helps
Bruce F.
already tried, I'll let you move on
thank you
Mark M.
again, if anyone has a question, chime in
8:00 PM
Bruce F.
Same project as before. It doesn't compile because it doesn't generate R.java
Mark M.
that is because of that error
that error is usually caused by the build target being wrong
I have never seen that error in any other circumstance
if the other projects work fine, you will need to poke around and try to figure out what is wrong with that one project's configuration
Bruce F.
yep, that fixed it
I was looking at the wrong properties before.
Mark M.
ah, OK
8:10 PM
Mark M.
again, if anyone has a question, just ask
8:25 PM
Mark M.
we're running out of time -- any last questions?
8:30 PM
Bruce F.
has left the room
Mark M.
OK, that's a wrap for today's chat
Guille
thanks mark
Mark M.
next one is Tuesday, 10am Eastern Time
have a pleasant day, all!
Guille
has left the room
Chris
has left the room
Mark M.
turned off guest access

Tuesday, April 24

 

Office Hours

People in this transcript

  • Bruce Forkush
  • Chris
  • Guille
  • Mark Murphy