Nov 24 | 9:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Nov 24 | 10:15 AM |
Ales | has entered the room |
Mark M. |
howdy, Ales!
|
Ales |
Hi.
|
Ales |
Just a couple of questions
|
Mark M. |
go right ahead -- you are the only one here at the moment
|
Ales |
Can you give me an example of running (executing) apk file within my activity
|
Mark M. |
There is no such thing in Android
|
Mark M. |
you can start an activity in another APK via startActivity()
|
Ales |
Actually I would like to install it
|
Ales |
Now I do it via browser
|
Mark M. |
ah, OK
|
Ales |
Download apk and then user must select it (install)
|
Mark M. |
you can download the APK via HttpClient, assuming your browser access is via HTTP
|
Ales |
Is there any other way not using browser
|
Nov 24 | 10:20 AM |
Ales |
ok download i get but what then
|
Mark M. |
then, if I understand correctly, you can call
startActivity() on an ACTION_VIEW Intent, with the Uri to your
downloaded APK and the proper MIME type
|
Mark M. |
that MIME type is: application/vnd.android.package-archive
|
Mark M. |
that should start the install process (e.g., list of required permissions)
|
Mark M. |
note that I have not tried this yet, so I may be mis-remembering a step
|
Ales |
Ok, I'll give that a try...
|
Ales |
Second question would be
|
Ales |
about listst and adapter
|
Ales |
Where does one usually change data in list? In array of elements or directly in adapter?
|
Ales |
If I use array of strings for example
|
Mark M. |
if you want to add, insert, or remove strings, use the add(), insert(), and remove() methods on ArrayAdapter
|
Mark M. |
that way, the ListView (or Spinner or whatever) will automatically update to reflect the change
|
Ales |
In that case is notify... needed?
|
Mark M. |
no
|
Mark M. |
the add(), insert(), and remove() methods do that for you automatically
|
Nov 24 | 10:25 AM |
Ales |
And if I change the array, do I call notify after each insert or after last one?
|
Mark M. |
whatever you want
|
Mark M. |
all else being equal, I would wait until after the last one, if you are doing them in a loop or something
|
Ales |
ok thank you
|
Peter | has entered the room |
Ales |
I noticed 3.3 of your book is available. Changes?
|
Peter |
Hello all!
|
Mark M. | |
Mark M. |
howdy, Peter!
|
Peter |
could you give me some piece of advice?
|
Mark M. |
Peter: go ahead, it is your turn
|
Mark M. |
assuming the advice is somehow Android-related
|
Mark M. |
:-)
|
Peter |
:)
|
Peter |
it is
|
Peter |
I'd like to implement a custom marker to be displayed in my mapview
|
Peter |
I'm reading your advanced android chapter
|
Peter |
but the marker is not shown
|
Peter |
as it is expected
|
Mark M. |
did the sample code work originally?
|
Mark M. |
in other words, if you try, say, Maps/ILuvNooYawk without changes, does it work?
|
Nov 24 | 10:30 AM |
Peter |
I havent tried..:)
|
Mark M. |
if that fails, then something really strange is going on
|
Mark M. |
ok
|
Mark M. |
how are you setting up the marker?
|
Peter |
i assumed it has been tested
|
Peter |
:)
|
Peter |
i am creating my new overlay item
|
Peter |
and overriding the getMarker method
|
Mark M. |
getMarker() is a private method, part of my sample code implementation
|
Mark M. |
whoops, you mean getMarker() on your OverlayItem subclass, probably
|
Peter |
in which the drawable is constucted based upon the string which I give in constructor parameter
|
Mark M. |
(I was thinking getMarker() on my ItemizedOverlay)
|
Peter |
yes
|
Peter |
should I post the code itself?
|
Peter |
setState is not mandatory, is it?
|
Mark M. |
go ahead, though if it is long, you may want to use gist.github.com or some similar pastie site
|
Mark M. |
setState() certainly is advisable
|
Mark M. |
I do not recall if it is mandatory
|
Peter |
it is not long
|
Mark M. |
you can paste it right into the chat, then
|
Peter |
View paste
|
Nov 24 | 10:35 AM |
Peter |
the commented lines are the construction of the id
|
Mark M. |
well, your drawableId is 0
|
Peter |
of the drawable
|
Peter |
no-no
|
Peter |
:)
|
Mark M. |
but you cannot calculate drawable IDs this way
|
Peter |
just cut out the id construction phase
|
Mark M. |
drawable IDs are generated by aapt at compile time
|
Mark M. |
they are unpredictable
|
Mark M. |
what exactly are you trying to achieve?
|
Peter |
are they?
|
Peter |
trying to put status based markers
|
Mark M. |
you cannot even really rely on them staying the same from compile to compile, if you modify other resources
|
Peter |
on my mapview
|
Mark M. |
how many different statuses are there?
|
Peter |
a lot, because the drawable depends on the state and the name of the contact
|
Peter |
:/
|
Peter |
I assumed that the order does not change relativly to the startId
|
Mark M. |
you either need a static array or HashMap or
something of R.drawable.X values, or you will need to use
getResources().getIdentifier() to come up with an ID given that you
constructed the name as a string
|
Mark M. |
I would not rely upon the drawable integer values at all, particularly things like order
|
Nov 24 | 10:40 AM |
Peter |
ok, thanks good point
|
Peter |
I see that it is far from the best solution
|
Peter |
but
|
Peter |
assuming the id is good
|
Peter |
what may be the problem
|
Peter |
?
|
Mark M. |
I'm not aware there is a problem other than that
|
Mark M. |
in your current code, with the comment, you are attempting to get drawable ID 0, which will certainly not work
|
Mark M. |
if we assume that you fix things such that
drawableId is a valid resource ID, the rest seems OK or unused (e.g.,
the String[] states)
|
Mark M. |
you will need to make sure your drawables are StateListDrawables
|
Peter |
just logged out, the Id is fine, it is a valid drawable
|
Nov 24 | 10:45 AM |
Mark M. |
see Maps/ILuvNooYawk from the Advanced Android code for example StateListDrawable resource XML
|
Nov 24 | 10:45 AM |
Peter |
i'm just asking that is anything else needed to display the drawable
|
Peter |
?
|
Peter |
i must have missed sg
|
Mark M. |
not that I am aware of
|
Peter |
yes, the code is here in front of me ;)
|
Mark M. |
again, load up the Maps/ILuvNooYawk sample, play with it, and see where your getMarker() differs from the one I have
|
Mark M. |
you might also use hierarchyviewer to take a peek at the map to see what is going on
|
Mark M. |
I have not used hierarchyviewer with an ItemizedOverlay, but I would assume the OverlayItems show up as ImageViews
|
SD | has entered the room |
Mark M. |
Peter: let me give the others a shot at questions, and I can swing back to you later for follow-up, if there is time
|
SD |
hi
|
Mark M. |
howdy, SD! do you have a question?
|
SD |
yes
|
Peter |
ok, thanks for the advice
|
SD |
I have a question about requestLocationUpdates with pendingIntent.
|
SD |
View paste
|
Mark M. |
"If the provider's status changes, an intent will
be sent with an extra with key KEY_STATUS_CHANGED and an integer value
indicating the new status. Any extras associated with the status update
will be sent as well."
|
Mark M. |
from http://developer.android.com/reference/and…, long, float, android.app.PendingIntent)
|
Mark M. |
er, never mind that link
|
Mark M. |
from the docs on requestLocationUpdates() (the PendingIntent flavor)
|
Nov 24 | 10:50 AM |
Mark M. |
so, check your KEY_STATUS_CHANGED extra, and I would expect it to have values like the status ones from your question
|
SD |
what happens when device does not have cell
provide service and also does not have wifi signal. In this case I see
that pendingIntent never gets fired.
|
Mark M. |
beats me
|
Mark M. |
if you are requesting GPS, I would expect the PendingIntent to eventually be invoked once you got a fix
|
Mark M. |
if you do not have a GPS signal, either, I suppose it may never fire
|
Mark M. |
I have not looked at the implementation, nor have I
played with this much on hardware in various scenarios, so I am just
taking educated guesses here
|
SD |
ok..
|
Mark M. |
Ales: do you have another question?
|
Ales |
What was wrong with content provides from book?
|
SD |
I was doing something after checking
KEY_STATUS_CHANGED, or
status==LocationProvider.TEMPORARILY_UNAVAILABLE||status==LocationProvider.OUT_OF_SERVICE.
Wondering how /where can I handle the condition if pendingIntent never
gets fired.
|
Mark M. |
Ales: I am not comfortable with that being in an introductory text, and I want to document more patterns for using them
|
Mark M. |
SD: use AlarmManager to wake yourself up after such-and-so period, if you did not get a location fix
|
Mark M. |
Peter: do you have another question?
|
Nov 24 | 10:55 AM |
SD |
ok
|
Mark M. |
we are running out of time -- any last questions?
|
Ales |
You are from US right?
|
Mark M. |
yes
|
Peter |
yes, a moment..
|
Ales |
Thanks for your help and happy Thanksgiving from me :) bye
|
Mark M. |
Ales: thanks!
|
Ales | has left the room |
Peter |
may your outer getMarker() count?
|
SD |
if I am using requestLocationUpdates from a service, when the device goes to sleep, will on locationChanged still gets fired.
|
Peter |
View paste
|
Mark M. |
Peter: that is simply a helper method to prep a Drawable
|
Mark M. |
SD: no, if the device goes to sleep, you will not get location fixes
|
Peter |
ok, tthank you, I have no other ideas..
|
Nov 24 | 11:00 AM |
SD |
so the weatherPlus example from your book is doing similar thing... right? How to then get location updates in the background?
|
Mark M. |
you need to keep the device awake while you wait for fixes
|
Mark M. |
the WeatherPlus example is not designed for dealing with sleeping devices
|
SD |
ok
|
Mark M. |
that is all for today's chat
|
Mark M. |
the next chats are in two weeks, since my travel schedule next week is a little strange
|
Mark M. |
have a pleasant day, everyone!
|
Peter |
thanks
|
SD |
thanks
|
Peter |
you too!
|
Peter | has left the room |
SD | has left the room |
Mark M. | turned off guest access |