Android Learning-Application Fundamentals
Application Fundamentals
URL: http://developer.android.com/guide/topics/fundamentals.htmlHowever, there are ways for an application to share data with other applications and for an application to access system services:
- It's possible to arrange for two applications to share the same Linux user ID, in which case they are able to access each other's files. To conserve system resources, applications with the same user ID can also arrange to run in the same Linux process and share the same VM (the applications must also be signed with the same certificate).
- An application can request permission to access device data such as the user's contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All application permissions must be granted by the user at install time.
four types of application components
An activity is implemented as a subclass ofActivity
and you can learn more about it in theActivitiesdeveloper guide.
Aserviceis 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 ofService
and you can learn more about it in theServicesdeveloper guide.
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, theNote Padsample application uses a content provider to save notes.
A content provider is implemented as a subclass ofContentProvider
and must implement a standard set of APIs that enable other applications to perform transactions. For more information, see theContent Providersdeveloper guide.
A broadcast receiver is implemented as a subclass ofBroadcastReceiver
and each broadcast is delivered as anIntent
object. For more information, see theBroadcastReceiver
class.
A unique aspect of the Android system design is that any application can start another application’s component.
When the system starts a component, it starts the process for that application (if it's not already running) and instantiates the classes needed for the component.
Therefore, unlike applications on most other systems, Android applications don't have a single entry point (there's nomain()
function, for example).
to activate a component in another application, you must deliver a message to the system that specifies yourintentto start a particular component. The system then activates the component for you.
activities(startActivity or startActivityForResult), services(startService, bindService), and broadcast receivers—are activated by an asynchronous message called anintent.
initiate a broadcast: sendBroadcast, sendOrderedBroadcast or sendStickyBroadcast
perform a query to a content provider by calling query on a contentResolver
The other component type, content provider, is not activated by intents. Rather, it is activated when targeted by a request from aContentResolver
.
Activities, services, and content providers that you include in your source but do not declare in the manifest are not visible to the system and, consequently, can never run. However, broadcast receivers can be either declared in the manifest or created dynamically in code (asBroadcastReceiver
objects) and registered with the system by callingregisterReceiver()
.
The way the system identifies the components that can respond to an intent is by comparing the intent received to theintent filtersprovided in the manifest file of other applications on the device.
Most of the requirement declarations are informational only and the system doesn't read them, but external services such as Android market do read them in order to provide filtering for users when they search for applications from their device.
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer