Sunday, October 31, 2010

titbits left out from the Android documentation

Excellent explanation by Dick Wall (from thread


This is a MIME type - MIME stands for Multimedia Internet Mail Extensions
and was created for email attachments to tell the receiving computer what
type of file was attached and give it a clue on how to deal with it. It has
since been adopted as a pretty well used standard for general typing of
files, e.g. it is common to see something like "audio/mp3" to indicate an
audio mp3 file.

There are generally two parts - a category (before the / ) and a specific
type (after the / ).

In this case, our category is an android cursor item - because this is
pretty specific, the vnd indicates that this is a "vendor" definition - i.e.
we defined it, and quite possibly other people don't agree with our
unilateral definition (although the IANA will register such things if asked
which makes it official - sort of...)

The means that this is a note type, for Google, and again
vendor defined

So, if your organization was and your item was a superthingy,
you might use: (the category is still an
android cursor item assuming you want to return it through a cursor...)

For more info on MIME, I can suggest the following links: (this one is a bit heavy, but contains
the actual RFCs that define the standards if you really want to know what
makes it tick - you don't need to read all this to get along with MIME types

2) In the line "
android:value="" />"...

The "" is just a string that
your manifest and your Java source code constants can agree on, that said
there is a convention in use here that should probably be adhered to in
order to avoid trouble.

In Java source code, source is organized into packages that look like:



The first two parts of the package usually correspond to an internet domain
name that the author owns or is associated with, so for example, Google owns, so many of our packages start with (note the reversal
- packages in Java source get more specific as they progress, so com being
the most general term is used first).

Going with the example, if you own that you could use


to put your source code in.

The actions follow this same convention, but tend to put an extra .action.
before the actual action name you want to use, so:

org.hepcats.bonanzanotes.action.EDIT_MY_STUFF might be something you used.
Alternatively it is not wrong to put android in there after hepcats as well
as a further categorization of what you are writing (as in "this is my
android code"), so you might use instead.

3) In the following lines, what do 'DEFAULT', 'ALTERNATIVE', and

These are convenience definitions provided for you by Android itself.
DEFAULT means that this action can be considered a default action for the
type of data specified - i.e. something requesting the default action for a
particular data item can get sent straight to this intent. It's like saying
"I know this one, let me handle it"

ALTERNATIVE means that this can act as one of the alternatives that the user
can select to handle a particular request or item. If there are several
alternatives, the user will (or may) be prompted as to which one to use.

SELECTED_ALTERNATIVE means that the action applies to something the user
currently has selected.

You can read a lot more about all this in the Intent class reference:

There is plenty of meaty documentation on this, and it should fill in any
gaps in my explanation.

No comments: