Office Hours — Today, November 24

Yesterday, November 23

Nov 24
9:50 AM
Mark M.
has entered the room
Mark M.
turned on guest access
10:15 AM
Ales
has entered the room
Mark M.
howdy, Ales!
Ales
Hi.
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
you can start an activity in another APK via startActivity()
Ales
Actually I would like to install it
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
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
that MIME type is: application/vnd.android.package-archive
that should start the install process (e.g., list of required permissions)
note that I have not tried this yet, so I may be mis-remembering a step
Ales
Ok, I'll give that a try...
Second question would be
about listst and adapter
Where does one usually change data in list? In array of elements or directly in adapter?
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
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
the add(), insert(), and remove() methods do that for you automatically
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
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.
howdy, Peter!
Peter
could you give me some piece of advice?
Mark M.
Peter: go ahead, it is your turn
assuming the advice is somehow Android-related
:-)
Peter
:)
it is
I'd like to implement a custom marker to be displayed in my mapview
I'm reading your advanced android chapter
but the marker is not shown
as it is expected
Mark M.
did the sample code work originally?
in other words, if you try, say, Maps/ILuvNooYawk without changes, does it work?
10:30 AM
Peter
I havent tried..:)
Mark M.
if that fails, then something really strange is going on
ok
how are you setting up the marker?
Peter
i assumed it has been tested
:)
i am creating my new overlay item
and overriding the getMarker method
Mark M.
getMarker() is a private method, part of my sample code implementation
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
should I post the code itself?
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
setState() certainly is advisable
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
 @Override
        public Drawable getMarker(int stateBitset) {

            String[] states = getResources().getStringArray(R.array.presence_status);
            int startId = R.drawable.loc_brown_a;
            int drawableId = 0;

             //...   drawableId = startId + 156 + numValueofChar - 10;
            }
            Drawable d = getResources().getDrawable(drawableId);
            Log.d(TAG, "Trying to get marker with ID: " + drawableId);
            setState(d, stateBitset);
           
            return d;
        }
10:35 AM
Peter
the commented lines are the construction of the id
Mark M.
well, your drawableId is 0
Peter
of the drawable
no-no
:)
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
they are unpredictable
what exactly are you trying to achieve?
Peter
are they?
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
:/
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
I would not rely upon the drawable integer values at all, particularly things like order
10:40 AM
Peter
ok, thanks good point
I see that it is far from the best solution
but
assuming the id is good
what may be the problem
?
Mark M.
I'm not aware there is a problem other than that
in your current code, with the comment, you are attempting to get drawable ID 0, which will certainly not work
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)
you will need to make sure your drawables are StateListDrawables
Peter
just logged out, the Id is fine, it is a valid drawable
10:45 AM
Mark M.
see Maps/ILuvNooYawk from the Advanced Android code for example StateListDrawable resource XML
10:45 AM
Peter
i'm just asking that is anything else needed to display the drawable
?
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
you might also use hierarchyviewer to take a peek at the map to see what is going on
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.
View paste
Does pendngIntent always Fire? How to take care of condition - Out of network or no service available?
Will it fire with status==LocationProvider.TEMPORARILY_UNAVAILABLE||status==LocationProvider.OUT_OF_SERVICE ?
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."
from http://developer.android.com/reference/and…, long, float, android.app.PendingIntent)
er, never mind that link
from the docs on requestLocationUpdates() (the PendingIntent flavor)
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
if you are requesting GPS, I would expect the PendingIntent to eventually be invoked once you got a fix
if you do not have a GPS signal, either, I suppose it may never fire
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
SD: use AlarmManager to wake yourself up after such-and-so period, if you did not get a location fix
Peter: do you have another question?
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
private Drawable getMarker(int resource) {
			Drawable marker=getResources().getDrawable(resource);
			
			marker.setBounds(0, 0, marker.getIntrinsicWidth(),
												marker.getIntrinsicHeight());
			boundCenter(marker);

			return(marker);
		}
Mark M.
Peter: that is simply a helper method to prep a Drawable
SD: no, if the device goes to sleep, you will not get location fixes
Peter
ok, tthank you, I have no other ideas..
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
the WeatherPlus example is not designed for dealing with sleeping devices
SD
ok
Mark M.
that is all for today's chat
the next chats are in two weeks, since my travel schedule next week is a little strange
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

Yesterday, November 23

 

Office Hours

People in this transcript

  • Ales
  • Mark Murphy
  • Peter
  • SD