Application Fundamental Android

Primary class for user interaction
Usually implements a single, focused task that the user can do

Run in the background
To perform long-running operations
To support interaction with remote processes

Component that listens for and responds to events
The subscriber in publish/subscribe pattern
Events represented by the intent class and the broadcast
BroadcastReceiver receives and responds to broadcast event

Content Providers
Store & share data across applications
- Uses database-style interface
- Handles interprocess communication


Participation in the build process will usually involve the four steps:
Define Resources
- Resources are non-source code entities
Implement Application Classes
Package Application
Install & run application

User Interface Layout
UI layout specified in xml files
XML files typically stored in res/layout/*.xml
Accessed in Java as: R.layout.layout_name
Can specify different layout files based on your device's orientation, screen size, etc.
At compilation time, resources are used to generate the class
Java code uses the R class to access resources

Implement Classes
Usually involves at least one Activity
Activity initialization code usually in onCreate()
- Restore saved state
- Set content view
- Initialize UI elements
- Link UI elements to code Actions

Package Application
System packages application components & resources into a .apk file
Developers specify required application information in a file called

Navigation through activities
Android supports navigation in several ways
- a task is a set of related activities
- These related activities don't have to be part of the same application
- Most tasks start at the home screen
The task backstack
- when an activity is launched, it goes on top of the backstack
- when the activity is destroyed, it is popped off the backstack
Suspending & resuming activities

The Activity Lifecycle

Called when activity is created
Sets up initial state
- Call super.onCreate()
- Set the activity's content view
- Retain references to UI views as necessary
- Configure views as necessary

Starting Activities
Pass newly created intent to methods, such as:
- Invokes a callback method when the called activity finishes to return a result


The Android documentation describes an Activity as "a single, focused thing that the user can do." Which one of the following statements best expresses why this statement might be somewhat ambiguous today?
Some devices, such as Tablets, are large enough to accommodate multiple screenfuls of data at one time.

Which one of the following statements might explain why the Music application plays songs using a Service, rather than by using one of its Activities?
The user might want to listen to music and do something else at the same time.

The MediaPlaybackService class that we looked at earlier in the lecture is a Service. Did you notice that it also contains a BroadcastReceiver called mIntentReceiver? What BroadcastReceiver method is overriden in the file by mIntentReceiver?

Which of the following statements about the ContentProvider class are true?
ContentProviders can perform interprocess communication.
ContentProviders encapsulate data sets.
Android supports several system-wide ContentProviders.

Which one of the four fundamental components of Android applications is designed to provide an interface to the user?

Which one of the four fundamental components of Android applications is designed to listen for and respond to events?

Which one of the four fundamental components of Android applications is designed for sharing data across applications?

Which one of the four fundamental components of Android applications is designed to in-the-background and remote operations?

Resources are non-source code entities within your application. Which of the following statements capture advantages of using resources, rather than managing entities directly within application source code?
Resources can be changed without recompiling source code.
Sets of resources can be created for different devices, user preferences, and devices configurations.

If you create a resource, such as a string resource, in an XML file, how can you access that resource in your Java code?
In your Java code you can refer to a string, called "string_name", as R.string.string_name.

In which level of the Android Platform would you find the Activity, Service, BroadcastReceiver, and ContentProvider classes?
The Application Framework Layer

Customizing strings for different languages allows more people to use your application, but it's not always that easy to do. Have you thought about some of the difficulties that might come from trying to support users of many different languages? Which of the following might be examples of such difficulties?
Left-to-right vs. right to left ordering of words
Differing word lengths for the same concept.
Differing date and time formats.
Ensuring that the translation is correct.

In which directory did we put the main.xml layout file that specifies MapLocation's layout when the device is in landscape mode?

The Button.onClickListener interface defines a "callback" method. A callback method is a method that will get called at a future time, in this case, whenever the user clicks on a particular Button. What is the name of the callback method where you put code to be executed when a user clicks on a Button?

In which method are Activities usually initialized?

Which of the following are examples of element tags that you might find in an AndroidManifest.xml file? See: for more information.

Which of the following are advantages of using an emulator instead of using a device?
You don't have to buy an actual device.
The emulated hardware is reconfigurable.
Changes to the emulator state don't make permanent changes to a device.

Which one of the following statements best captures a common design theme or principle for Android Activities?
Each Activity should support one focused thing that the user can do.

Which one of the following steps is typically done in onCreate()?
Set the Activity's content view.

When an Activity calls startActivityForResult(), it will eventually receive a callback to which of its methods?

When one Activity wants to start another activity it creates an Object that specifies which Activity it wants to start. What is the type of this Object?

Marcos Carvalho

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *