Oct 26 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 26 | 4:05 PM |
Mark M. |
testing...just had an Internet outage here
|
Oct 26 | 4:10 PM |
Kevin M. | has entered the room |
Kevin M. |
Hello!
|
Mark M. |
howdy, KEvin!
|
Mark M. |
er, Kevin
|
Kevin M. |
I was the one who asked about different hours
|
Kevin M. |
so this is a good time
|
David | has entered the room |
Mark M. |
if you'd like, I can wait until you go find a bus :-)
|
Kevin M. |
Lots of questions
|
Kevin M. |
:)
|
Mark M. |
fire off your first one, then we'll give David a shot
|
David |
Hi Mark
|
Mark M. |
(btw, howdy, David!)
|
Kevin M. |
I have 1 big one but I'll start off with a smaller one: How do you capture keys when asleep
|
Kevin M. |
i.e. when the display is dark
|
Mark M. |
You don't
|
Kevin M. |
I have a music program that I would like to use the camera button to pause/resume the music
|
Ales | has entered the room |
Mark M. |
then the device is not asleep
|
Mark M. |
otherwise, it can't be playing music
|
Kevin M. |
Right. I have a service that is running but it doesn't seem to receive broadcasts
|
Oct 26 | 4:15 PM |
Mark M. |
presumably, you are holding a WakeLock, one way or another
|
Kevin M. |
yes
|
Mark M. |
the only WakeLock level that supports keyboard events is a FULL_WAKE_LOCK
|
Mark M. |
(btw, howdy, Ales!)
|
Ales |
Hello everyone :)
|
Mark M. |
so, it may be you cannot receive ACTION_CAMERA_BUTTON without a FULL_WAKE_LOCK
|
Kevin M. |
Ahh...But that will keep the screen on too, right?
|
Mark M. |
yes
|
Mark M. |
I don't know of a way around that
|
Kevin M. |
So it doesn't sound doable
|
Mark M. |
it may be that the WakeLock docs are just too terse
|
Mark M. |
so you might try something stronger than
PARTIAL_WAKE_LOCK but less than FULL_WAKE_LOCK and see if you start
getting ACTION_CAMERA_BUTTON broadcasts
|
Mark M. |
otherwise, I think you may be stuck
|
Kevin M. |
The other question I have (and you can postpone it
for others if you want) is about lifescyles. I have a series of
activities that get started from each other.
|
Mark M. |
wait, whoa
|
Mark M. |
let's give everyone else a shot, then we'll swing back to you
|
Kevin M. |
Sure
|
Mark M. |
David: do you have a question?
|
David |
It is said that android.provider.Calendar is in @hide. How can I get the file and how to make unhide?
|
Mark M. |
You can't unhide it
|
Mark M. |
And you definitely do not want to be using it
|
Mark M. |
Please use the Google Calendar GData APIs for manipulating the user's Google Calendar
|
David |
I see.
|
David |
Okay.
|
Mark M. |
Ales: do you have a question?
|
Oct 26 | 4:20 PM |
Ales |
Kevin please go ahead with your question.
|
Mark M. |
cool by me -- Kevin: your turn again
|
Kevin M. |
So if I have Activity A, B, C, D
|
Kevin M. |
and I go home
|
Kevin M. |
and then press the home button to bring up the activity list and go back to my activity, I don't always go to the right one
|
Kevin M. |
I've been messing with the single_top type settings
|
Kevin M. |
Haven't been able to get it right
|
Mark M. |
what do you consider to be "the right one" and what is happening when you use the recent activities list
|
Mark M. |
?
|
Kevin M. |
I see my program but it now will take me back to the main activity instead of the top one
|
Mark M. |
OK
|
Kevin M. |
I want the onNewIntent method to be called so that I do get a new activity created each time
|
Mark M. |
by "top one", you mean the one that was last used by the user?
|
Kevin M. |
Yes
|
Oct 26 | 4:25 PM |
Mark M. |
so, if you have A->B->C->D, and user
presses HOME, and user clicks on you in the recent activities list,
instead of going back to D, you are getting a *new* copy of A?
|
Kevin M. |
Well, it's a bit more complicated as I've changed a lot of settings to figure it out
|
Kevin M. |
I've got A as singleTask
|
Kevin M. |
and the last one as singleTop
|
Kevin M. |
I don't want my music program to be recreated while it is playing
|
Mark M. |
which activity (A, B, C, or D) is the music program?
|
Kevin M. |
D
|
Kevin M. |
D is the music player activity
|
Kevin M. |
They can go through the albums, artists etc before getting there
|
Mark M. |
OK
|
Mark M. |
have you looked in DDMS to see what Intent is being sent when you tap on your icon in the recent activities list?
|
Kevin M. |
The B & C are normal but if I'm on C, when I return I want to be on C and not A
|
Oct 26 | 4:30 PM |
Mark M. |
(more accurately, looked in LogCat?)
|
NetApex | has entered the room |
Mark M. |
howdy, NetApex!
|
Kevin M. |
I've had breakpoints on the onNewIntent and OnCreate of each activity
|
NetApex |
Good afternoon
|
Mark M. |
Kevin: check LogCat and figure out what Intent is being used when you tap on the icon in the recent activities list
|
Mark M. |
your breakpoints will only tell you what responded
|
Mark M. |
you also need to figure out what Android is asking for
|
Mark M. |
I haven't played with recent activities much
|
Kevin M. |
Going from a notification works great, just the recent doesn't work right
|
Mark M. |
which presumably means the recent is using a different Intent
|
Kevin M. |
Seems like it
|
Mark M. |
you need to figure out what that is, as that should help you figure out how best to respond
|
Mark M. |
unfortunately, I don't have a ton of concrete advice for you, beyond that
|
Kevin M. |
Ok. Thanks
|
Mark M. |
NetApex: do you have a question, since you haven't had a shot yet
|
Mark M. |
?
|
NetApex |
Nope, just along for the ride at the moment
|
Mark M. |
OK
|
Mark M. |
David: do you have a question?
|
David |
Mark, I want to Google Calendar source code to
make an Android calendar. Is it the right way to replace
android.provider.Calendar class with Google Calendar GData APIs?
|
Mark M. |
The android.provider.Calendar class is not part of the SDK
|
Oct 26 | 4:35 PM |
Mark M. |
It might not even be part of the Android installation on any given device
|
David |
I know, but source code uses it.
|
Mark M. |
So?
|
David |
Can I replace with GData APIs?
|
Mark M. |
you can manipulate the user's Google Calendar with GData APIs
|
David |
OK
|
Mark M. |
the changes you put out there will eventually sync
to their Calendar app, if they have one and if they have configured it
for such synchronization
|
Mark M. |
it also will work if they do not use the native Calendar app (e.g., they use some other Google Calendar app)
|
David |
Thanks
|
Mark M. |
Ales: do you have a question?
|
Ales |
I have similar question as Kevin. I am building
news app and have 5 activities (news, weather, traffic,..). I can get
from each activity to any of other 4.
|
Ales |
View paste
|
Mark M. |
I am not sure that a flag will be the right answer in this case
|
Oct 26 | 4:40 PM |
Mark M. |
hold on
|
Mark M. |
actually, it looks like FLAG_ACTIVITY_REORDER_TO_FRONT will be what you want
|
Mark M. |
"For example, consider a task consisting of four
activities: A, B, C, D. If D calls startActivity() with an Intent that
resolves to the component of activity B, then B will be brought to the
front of the history stack, with this resulting order: A, C, D, B."
|
Ales |
I just don't want activities to create more and more instances of themself
|
Ales |
Because phone crashes
|
Mark M. |
makes sense, though the phone should not crash
|
Mark M. |
Android will clean up the activities
|
Mark M. |
Kevin: do you have another question?
|
Kevin M. |
Yes. If you have an activity that starts a
service, then the user returns from that activity, the service will no
longer run right?
|
Mark M. |
that depends
|
Mark M. |
when you say "starts a service" are you using bindService() or startService()?
|
Oct 26 | 4:45 PM |
Kevin M. |
bindService
|
Kevin M. |
and then in onDestroy it calls unbind
|
Mark M. |
then the service will run until the matching
unbindService(), unless some other activity has bound to the service, or
unless something else called startService()
|
Mark M. |
so, if there's nothing else working with your
service, it will shut down shortly after your activity is destroyed,
given your description above
|
Kevin M. |
I ended up creating a service in activity A that holds on to a copy of the other service to keep it around. Very ugly
|
Mark M. |
gack
|
Mark M. |
that does not sound good
|
Kevin M. |
I have a download service that needs to keep running even if the activity that started it closes
|
Mark M. |
then that should be used with startService(), not bindService()
|
Kevin M. |
Oh, so then can I get away with not calling stopService?
|
Kevin M. |
Just let it finish?
|
Mark M. |
ideally, the download service would be an IntentService
|
Mark M. |
this solves two problems:
|
Mark M. |
1. it automatically does your work on a background thread
|
Mark M. |
2. it automatically shuts down when the work is done
|
Kevin M. |
Good idea. I just started using the IntentService. I thought I needed a regular one
|
Mark M. |
if you are concerned about the device going to
sleep, you might consider making it a WakefulIntentService, as seen in
the Advanced Android book
|
Kevin M. |
Right. I copied that code. :)
|
Mark M. |
a download-even-if-user-exits scenario is perfect for an IntentService
|
Oct 26 | 4:50 PM |
Mark M. |
in the next round of updates to my books, I plan on trying to drive that point home a bit better :-)
|
Kevin M. |
Cool
|
NetApex |
And to give some examples on using parcels in creative ways I hope!
|
Mark M. |
well, I'll try
|
NetApex |
I keep looking at it thinking what an awesome idea it is, but I go brain dead when it comes to using it :)
|
Mark M. |
particularly nowadays, parcels have fallen back to mostly being Android library projects with a naming convention
|
Mark M. |
you'd create one whenever you want to ship a reusable component that needs stuff like resources that don't fit in a pure JAR
|
Mark M. |
David: do you have another question?
|
Ales |
If I start service in activity A with
bindService(new Intent(this, MyService.class), onService,
BIND_AUTO_CREATE), how can I get access to the same service in activity B
(users goes from A to B after service binds to A)?
|
David |
NO
|
Mark M. |
Ales: you bind to it, same as you did with A
|
Ales |
And that will be the same service right?
|
Mark M. |
assuming you have not unbound from it in A, yes
|
Ales |
Or restarted if stopped
|
Mark M. |
yes
|
Ales |
ok perfect
|
Ales |
One suggestion if I may
|
Mark M. |
sure
|
David | has left the room |
Oct 26 | 4:55 PM |
Ales |
Please try to further explain custom adapters, views and lists in your book
|
Ales |
Chapter "A Dynamic Presentation"
|
Mark M. |
there's a whole chapter on tailoring adapters -- Fancy ListViews -- in The Busy Coder's Guide to Android Development
|
Ales |
I copied all the code and kinda make things work but did not actually understood what I was doing
|
Mark M. |
I have rewritten parts of that chapter in the most recent update to that book, which was released this past Friday
|
Mark M. |
perhaps the newer changes will help you
|
Ales |
I hope so
|
Mark M. |
any final questions from anyone?
|
Ales |
For example
|
Ales |
super(DynamicDemo.this, R.layout.row, items);
|
Ales |
View row=inflater.inflate(R.layout.row, parent, false);
|
Mark M. |
there's a whole section on view inflation
|
Mark M. |
with respect to the first line, that's actually covered better in the rewrite, I think
|
Ales |
Must adapter and View have the same resource
|
Mark M. |
not really
|
Oct 26 | 5:00 PM |
Ales |
Hmm
|
Mark M. |
read the revised chapter
|
Ales |
Ok will do. Thanks for your help
|
Mark M. |
OK, that's it for today's chat
|
Mark M. |
next one is next Tuesday, same time
|
Mark M. |
have a pleasant day, all!
|
NetApex |
see you next week
|
Ales |
bye
|
Kevin M. |
See you
|
Ales | has left the room |
Kevin M. | has left the room |
NetApex | has left the room |
Mark M. | turned off guest access |