Herramientas de usuario

Herramientas del sitio


fw:android1

¡Esta es una revisión vieja del documento!


Android (new)

Beginning

Instalation

Applications

There are several classes inside the SDK which are useful to develop Android applications…

  • Activity: Is the main class to develop user interaction. Usually they implement are focused on a single action.
  • Services: They run in the background while other applications are also running. They can perform long running actions or support interaction with other processes.
  • Broadcast Receiver: Are subscribers\listeners to events (like the SMS reception…).
  • Content Provider: Are sub-applications to exchange data between applications. They use a database style interface.

Resources

Strings

Strings are stored in res/values/*.xml file, can store visual styles as well as text, and there are three types:

  1. Current strings
  2. String array
  3. Plurals: Plural values for single strings.

A string definition is:

<string name="hello">Hello world!</string>

To access them from other resources we will do:

@string/string_name

Tools

LogCat

It's the Android main logs viewer. To use it you only need to import the android.util.Log class and call it:

  • Log.i(ID, MSG), produces an INFO message.
  • Log.d(ID, MSG), produces a DEBUG message.
  • Log.e(ID, MSG), produces an ERROR message.
  • Log.v(ID, MSG), produces a VERBOSE message.

Communication with the emulator

Url for the device is localhost accessed with the port specified on the window title of the emulator.

To access from other emulator, this number will act as the phone number (p.ex. to send SMS).

If the number on the window title was 5554, then the command to connect by telnet to the emulator would be:

$ telnet 127.0.0.1 5554

I could emulate an SMS from 5556 number using the command:

sms send 5556 "hi!"

Other commands to configure the emulator could be:

  • network speed edge
  • network speed full
  • power status not-charging
  • geo fix 0.00 0.40

DDMS

It's accessed from Eclipse as another perspective. It has several sub-applications which could be useful…

  • Dumb view hierarchy to UI auotomator. It obtains the UI structure from the currently loaded program.
  • Heap view. Where you can monitor the used resources from an application.
    • Update heap button will let you view the current heap consumption.
    • In heap tab, cause gc button will let you view more details about created objects.
    • Start and stop method profiling buttons will show more detailed views about inner methods inside the code.

Notes

Other capabilities

Multilanguage applications

You only need to add another resource folder which name ends with the country code target. P.ex, for spanish it would be: values-es.

fw/android1.1391467991.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)