Mudanças entre as edições de "Os 4 tipos de componentes"
(Criou página com '; '''Activities''' : An ''activity'' represents a single <nowiki> </nowiki>screen with a user interface. For example, an email application might have one activity that shows...') |
|||
Linha 1: | Linha 1: | ||
; '''Activities''' | ; '''Activities''' | ||
− | + | An ''activity'' represents a single<nowiki> </nowiki>screen with a user interface. For example, an email application might | |
− | <nowiki> </nowiki>screen with a user interface. For example, an email application might | + | |
have one activity that shows a list of new emails, another activity to | have one activity that shows a list of new emails, another activity to | ||
compose an email, and another activity for reading emails. Although the | compose an email, and another activity for reading emails. Although the | ||
Linha 10: | Linha 9: | ||
start the activity in the email application that composes new mail, in | start the activity in the email application that composes new mail, in | ||
order for the user to share a picture. | order for the user to share a picture. | ||
− | |||
An activity is implemented as a subclass of <code>Activity</code> and you can learn more about it in the Activities developer guide. | An activity is implemented as a subclass of <code>Activity</code> and you can learn more about it in the Activities developer guide. | ||
; '''Services''' | ; '''Services''' | ||
− | + | A ''service'' is a component that runs in the background to perform long-running operations or to perform | |
− | runs in the background to perform long-running operations or to perform | + | |
work for remote processes. A service does not provide a user interface. | work for remote processes. A service does not provide a user interface. | ||
For example, a service might play music in the background while the user | For example, a service might play music in the background while the user | ||
Linha 20: | Linha 17: | ||
without blocking user interaction with an activity. Another component, | without blocking user interaction with an activity. Another component, | ||
such as an activity, can start the service and let it run or bind to it | such as an activity, can start the service and let it run or bind to it | ||
− | in order to interact with it. | + | in order to interact with it. |
− | + | ||
A service is implemented as a subclass of <code>Service</code> and you can learn more about it in the Services developer guide. | A service is implemented as a subclass of <code>Service</code> and you can learn more about it in the Services developer guide. | ||
; '''Content providers''' | ; '''Content providers''' | ||
− | + | A ''content provider'' manages a shared set of application data. You can store the data in the | |
− | manages a shared set of application data. You can store the data in the | + | |
file system, an SQLite database, on the web, or any other persistent | file system, an SQLite database, on the web, or any other persistent | ||
storage location your application can access. Through the content | storage location your application can access. Through the content | ||
Linha 32: | Linha 27: | ||
content provider that manages the user's contact information. As such, | content provider that manages the user's contact information. As such, | ||
any application with the proper permissions can query part of the | any application with the proper permissions can query part of the | ||
− | content provider (such as <code>ContactsContract.Data</code>) to read and write information about a particular person. | + | content provider (such as <code>ContactsContract.Data</code>) to read and write information about a particular person. |
− | + | ||
Content providers are also useful for reading and writing data that | Content providers are also useful for reading and writing data that | ||
is private to your application and not shared. For example, the Note Pad sample application uses a content provider to save notes. | is private to your application and not shared. For example, the Note Pad sample application uses a content provider to save notes. | ||
− | A content provider is implemented as a subclass of <code>ContentProvider</code> | + | A content provider is implemented as a subclass of <code>ContentProvider</code>and must implement a standard set of APIs that enable other |
− | + | ||
applications to perform transactions. For more information, see the Content Providers developer guide. | applications to perform transactions. For more information, see the Content Providers developer guide. | ||
; '''Broadcast receivers''' | ; '''Broadcast receivers''' | ||
− | + | A ''broadcast receiver'' is a component that responds to system-wide broadcast announcements. | |
− | is a component that responds to system-wide broadcast announcements. | + | |
Many broadcasts originate from the system—for example, a broadcast | Many broadcasts originate from the system—for example, a broadcast | ||
announcing that the screen has turned off, the battery is low, or a | announcing that the screen has turned off, the battery is low, or a | ||
Linha 52: | Linha 45: | ||
<nowiki> </nowiki>a broadcast receiver is just a "gateway" to other components and is | <nowiki> </nowiki>a broadcast receiver is just a "gateway" to other components and is | ||
intended to do a very minimal amount of work. For instance, it might | intended to do a very minimal amount of work. For instance, it might | ||
− | initiate a service to perform some work based on the event. | + | initiate a service to perform some work based on the event. |
− | + | ||
A broadcast receiver is implemented as a subclass of <code>BroadcastReceiver</code> and each broadcast is delivered as an <code>Intent</code> object. For more information, see the <code>BroadcastReceiver</code> class. | A broadcast receiver is implemented as a subclass of <code>BroadcastReceiver</code> and each broadcast is delivered as an <code>Intent</code> object. For more information, see the <code>BroadcastReceiver</code> class. | ||
[[Categoria:Android]] | [[Categoria:Android]] |
Edição atual tal como às 09h14min de 27 de abril de 2015
- Activities
An activity represents a single screen with a user interface. For example, an email application might
have one activity that shows a list of new emails, another activity to
compose an email, and another activity for reading emails. Although the
activities work together to form a cohesive user experience in the email
application, each one is independent of the others. As such, a
different application can start any one of these activities (if the
email application allows it). For example, a camera application can
start the activity in the email application that composes new mail, in
order for the user to share a picture.
An activity is implemented as a subclass of Activity
and you can learn more about it in the Activities developer guide.
- Services
A service is a component that runs in the background to perform long-running operations or to perform
work for remote processes. A service does not provide a user interface.
For example, a service might play music in the background while the user
is in a different application, or it might fetch data over the network
without blocking user interaction with an activity. Another component,
such as an activity, can start the service and let it run or bind to it
in order to interact with it.
A service is implemented as a subclass of Service
and you can learn more about it in the Services developer guide.
- Content providers
A content provider manages a shared set of application data. You can store the data in the
file system, an SQLite database, on the web, or any other persistent
storage location your application can access. Through the content
provider, other applications can query or even modify the data (if the
content provider allows it). For example, the Android system provides a
content provider that manages the user's contact information. As such,
any application with the proper permissions can query part of the
content provider (such as ContactsContract.Data
) to read and write information about a particular person.
Content providers are also useful for reading and writing data that
is private to your application and not shared. For example, the Note Pad sample application uses a content provider to save notes.
A content provider is implemented as a subclass of ContentProvider
and must implement a standard set of APIs that enable other
applications to perform transactions. For more information, see the Content Providers developer guide.
- Broadcast receivers
A broadcast receiver is a component that responds to system-wide broadcast announcements.
Many broadcasts originate from the system—for example, a broadcast
announcing that the screen has turned off, the battery is low, or a
picture was captured. Applications can also initiate broadcasts—for
example, to let other applications know that some data has been
downloaded to the device and is available for them to use. Although
broadcast receivers don't display a user interface, they may create a status bar notification
to alert the user when a broadcast event occurs. More commonly, though,
a broadcast receiver is just a "gateway" to other components and is
intended to do a very minimal amount of work. For instance, it might
initiate a service to perform some work based on the event.
A broadcast receiver is implemented as a subclass of BroadcastReceiver
and each broadcast is delivered as an Intent
object. For more information, see the BroadcastReceiver
class.