Office Hours — Today, March 29

Tuesday, March 27

Mar 29
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
10:00 AM
Hamish B.
has entered the room
Mark M.
howdy, Hamish!
how can I help you today?
Hamish B.
Hello
Apologies in advance, Mark, I'm sure you will have been asked this before.
When using the standard Task Manager on my Gingerbread device to kill running services, I see that some services, displayed in a different colour, soon "come back to life". I thought if a User task-killed a service then all the service's processes are killed and its alarms are cleared and nothing runs until the user explicitly relaunches the service herself. If that is the case, how do these services automatically restart. I am not rebooting my phone so the services cannot be being restarted from an OnBoot receiver.
Mark M.
what is "the standard Task Manager"?
do you mean the Settings app, where you are pressing Force Close?
or do you mean something else that your device manufacturer included with their device?
Hamish B.
Long press middle menu button and the recent task lists popup with abutton for Task Manager this is on a Samsung Galaxy s2
Mark M.
OK, that is unique to that device (or other Samsungs possibly)
they are most likely using the killBackgroundProcesses() method
this does not do a Force Stop
the process is treated as if there was a low-memory condition
Hamish B.
ah ok, so if it's a Force stop then everything is killed ?
Mark M.
and so the service can come back (e.g., START_STICKY)
right, Force Stop on 2.3+ nukes everything from orbit
and on 3.1+ prevents anything from running again until the user manually launches an activity
on 2.1 and earlier, there was a way for task killers to do this too
10:05 AM
Mark M.
(maybe 2.2 as well -- I forget the timing)
Hamish B.
"prevents anything from running again until the user manually launches an activity" even if it is registered for OnBoot broadcasts ?
Mark M.
correct
Hamish B.
if the service is a system service can it be killed by a Task Manager?
Mark M.
what do you consider a "system service" to be?
Hamish B.
A service running as system_user inside the framework?
Mark M.
AFAIK those are not "services" (i.e., Dalvik VM apps with a class inheriting from android.app.Service)
those are processes that we interact with via AIDL
and, no, those cannot be killed by a task manager
most cannot be stopped by Settings, either, IIRC
10:10 AM
Mark M.
if you have other questions, feel free to chime in, at least until somebody else shows up :-)
Daniel B.
has entered the room
Mark M.
howdy, Daniel!
Hamish B.
i was thinking more of system apps? like the Alarm Clock or System Settings app ?
Daniel B.
Hello there
Mark M.
Hamish: apps can be killed by task killers, subject to the limitations we discussed
Daniel: do you have a question?
Daniel B.
Yes, I'm having issue with generating a spinner from a cursor. I have a SimpleCursorAdapter, but I think the issue I have is to do with either the projection or to paramaters. Because my spinner shows "empty" options for the number of rows I have. Example: I have 4 rows in the database, and the spinner shows 4 blank options
Mark M.
that sounds like an issue of binding data from the Cursor to the TextViews or other widgets
how are you doing that? overriding bindView()? using a ViewBinder? something else?
Daniel B.
I was able to get the data to display in a ListView, but not with a spinner.
10:15 AM
Daniel B.
Neither of those to my knowledge. I am rather new to android, and trying to pick pieces together from many sources so might have missed something
Mark M.
um, well, you gotta do something :-)
are you using SimpleCursorAdapter?
Daniel B.
Yup SimpleCursorAdapter
Mark M.
can you paste your SimpleCursorAdapter constructor call here?
Daniel B.
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, projection, to, 0);
Mark M.
projection and to should just have one value in each array -- correct?
Daniel B.
View paste
correct,         	String [] projection = {SubjectTable.COLUMN_NAME};
        	int[] to = new int[]{R.id.name_entry};
sorry that didn't paste too well, but you get point hopefully
Mark M.
android.R.layout.simple_spinner_item does not have a TextView with id R.id.name_entry
Daniel B.
oh I see
Mark M.
you probably had an R.id.name_entry in a custom row for your ListView
10:20 AM
Daniel B.
yup I did
Mark M.
that means either you need to create a custom row for your Spinner, or you need to adjust "to" to use the right ID
(which would be android.R.id.text1, BTW)
Daniel B.
Ah thank you. That does work now.
Mark M.
who-hoo!
Hamish: do you have another question?
10:25 AM
Nitin S.
has entered the room
Mark M.
howdy, Nitin!
Nitin: do you have a question?
Nitin S.
Hi Mark..
Yes
Culd you suggest me the best way to parse a JSON response?
Mark M.
how big is the JSON, and what versions of Android are you supporting?
Nitin S.
It can have 50-100 of JSON objects I suppose. Android 2.2+
mainly 2.2 & 2.3 as of now
Mark M.
I would start with the org.json classes (JSONObject and JSONArray)
10:30 AM
Mark M.
if you find that performance is an issue, consider Jackson as a third-party JAR
Nitin S.
okay. I'll check that. How good is GSON compared to Jackson?
Hamish B.
has left the room
Mark M.
I suspect that they are comparable, but I do not have performance statistics handy
Nitin S.
Okay.
Mark M.
note that API Level 11 added android.util.JsonReader, which is based on GSON
Nitin S.
Noted.
Mark, if I plan to develop a web apps, what are the few things I should make sure of? Some brief idea?
Mark M.
that is not my area of expertise, sorry
Daniel: do you have another question?
Nitin S.
Okay.
10:35 AM
Mark M.
if anyone has a question, chime in
Daniel B.
Is there a way to determine which Activity you entered the current Activity from? So that I can return the user to the correct one if they use the "up" navigation in the ActionBar?
Mark M.
not automatically
Nitin S.
I do. Have to seen the official TED app?
Mark M.
you can pass that info via an extra
Nitin: no, I have not
Nitin S.
Okay. AFAIK, how can we create a layout with multiple screens corresponding to the button at the top of every screen? Something like what Tabhost or ViewPager does.
10:40 AM
Mark M.
well, what do you want that TabHost or ViewPager do not do?
with respect to the TED app, based on Google Play screenshots, that is presumably a ViewPager if it supports horizontal swiping on the body
in terms of what they are using for their tab bar, that could be a styled TabHost, or a set of ToggleButtons, or just about anything
Nitin S.
Cool. Thank you. I liked the Interface of the app.
it does support horizontal swiping.
Mark M.
it is nicely polished, though I do not like the varying position of that tab bar thing
but, that's just me
Nitin S.
I am getting what's tab bar in it? I m running that app right now. :)
Mark M.
I am sorry, but I did not understand that question
Nitin S.
wait, let me check the screenshots in google play
10:45 AM
Nitin S.
Leave it. So a ViewPager supports both horizontal swiping and the clicks on those tabs?
Mark M.
ViewPager won't work with the tabs automatically, but you can arrange for it
see the JavaDocs for ViewPager for an example
using action bar tabs
Nitin S.
Okay. I'll look into that. Your book doesn't cover it?
Mark M.
right now, it doesn't even cover ViewPager
though the Omnibus will cover it in a couple of weeks
Nitin S.
Cool. I am looking forward to the pdf version.
Mark M.
(by "it" I mean ViewPager itself)
that is probably 3-4 weeks away
10:50 AM
Nitin S.
Okay. I am done for the day. Thanks for your time.
Mark M.
you are very welcome
Daniel: definitely chime in if you have more questions
Daniel B.
I'm out of questions for today. I'm just getting started, but I might have some for your next Office Hours, I was just staying around to get some further insight from others questions incase they helped me later :)
Mark M.
no problem
10:55 AM
Daniel B.
Thank you for the help and for the books. Will leave now, take care.
Mark M.
you are very welcome!
Daniel B.
has left the room
11:00 AM
Mark M.
that is a wrap for today's chat
next one is Wednesday at 7:30pm Eastern
have a pleasant day!
Nitin S.
has left the room
Mark M.
turned off guest access

Tuesday, March 27

 

Office Hours

People in this transcript

  • Daniel Bell
  • Hamish Brown
  • Mark Murphy
  • Nitin Sethi