Study notes: Android four points you must know knowledge, you know how much?

You do not know that knowledge of Android N series ...


Android four components

  • Activity (activities)
  • Service (Service)
  • Content provider (content provider)
  • BroadCast Recevicer (broadcast)

Activity (activities)

Reflects :

APP you can see in each individual window basically Activity.

Communication :

Activity data transfer between the use of inter-component communication Intent.

Use :

AndroidManifest.xml must be declared in the configuration file, the system can recognize Activity.


Service (Service)

Reflects :

Service is mainly used in the background to help complete the assigned task applications.

Use :

The label must declare all of the Service in AndroidManifest.xml profile. Service state is divided into two: Service is usually run in the background, and no UI interface, Service base class must inherit Service, Service commonly used to provide back-office services and monitor other components running.


Content provider (content provider)

Reflects :

Content Provider specified datasets to make an application available to other applications. Other applications may be provided by the content provider from the class ContentResolver acquired or stored data, to be understood that the middleman between the application content exchange . Only time across multiple applications need to share data, content providers have to reflect the value. For example, a plurality of contacts application content is acquired (QQ, micro-channel, pay treasure etc.), and must provide a content provider stored in. Its advantage is a unified data access. ContentProvider data sharing . ContentProvider used to store and retrieve data and make it visible to all applications. This is the only way to share data between different applications, as android application does not provide all public store commonly accessed.

Use :

Most developers are ContentResolver object that implements the operation of ContentProvider through , not directly. ContentProvider the URI to uniquely identify its data sets, where the URI to content: // prefix, indicating that the data is managed by ContentProvider.


BroadCast Recevicer (broadcast)

Reflects :

The main role of broadcasting is that external events will not be applied to filter out direct interest , analogy, WIFI disconnected broadcast reminders can use to make your applications receive and respond. Although there is no broadcast interface UI, but to start a Activity or Service Response message it receives, or to notify the user by NotificationManager . Notification reminders can use a variety of methods, the flash fires, vibration, play a sound, etc., in general, can be put directly on a clear status bar notification icon, users can open and check the news. Broadcast Registration divided into two types:

Use :

Registered broadcast receivers, there are two methods, namely static registration and dynamic registration AndroidManifest file .


Four components summary

registered

Four components basically have to register to use. Activity, service, Content Provider need to be configured in AndroidManifest file. AndroidManifest file does not declare the activity, service and content providers will not see the system and, thus, are not available. The broadcast receiver broadcast receivers registration points static registration (configured in AndroidManifest file) and to dynamically create and invoke Context.registerReceiver via code () way to registration system. Note that configuring the AndroidManifest file broadcast receiver will start with the system and has been active, as long as the interest received broadcast triggers (even though the program is not running).

Activate Use

Content provider activation: After receiving a request issued ContentResolver, the content provider is activated. activity, and the service is broadcast receiver called asynchronous message intent activated.

shut down

The content provider is active only when ContentResolver requesting a response. And a broadcast receiver in response to activation only when the broadcast information. Therefore, there is no need to explicitly close these components. Close Activity: An activity can be closed by calling its finish () method. Service shut down: For the method to start service to be invoked Context.stopService by startService () () method to close the service, use bindService () method to start service to be invoked Context.unbindService () method to close the service.


Additional knowledge

task

In fact, the task is to stack activity, which consists of one or more Activity composed together to accomplish a complete user experience. Bottom of the stack is to start the whole task Activity, top of the stack is currently running user can interact Activity, when a start another activity, the new activity was pushed onto the stack and become the activity currently running. The previous activity remains in the stack. When the user presses the BACK button, the current activity pop, but before a return to the Activity currently running. Save the stack is actually an object, stack Activity never rearranged, only pushed or popped. All activity task is to move as a whole. The entire task (ie activity stack) can be moved to the front desk, or retreat into the background. Android system is a multitasking (Multi-Task) operating system, you can listen to music while using a mobile phone, but also perform a number of other programs. Each additional execution of an application, it will take some multi-system memory, when too many programs simultaneously executed, or closed does not correctly freed memory, the system will feel more and more slowly, or even instability. To solve this problem, Android introduces a new mechanism, namely the life cycle (Life Cycle).

At last

I enclose my Android core technology learning syllabus, access to relevant content to play with my GitHub: https://github.com/Meng997998/AndroidJX

Well not a recent interview season, give you a welfare: 2017-2019 [byte beating interview Zhenti analytical & resume writing template PDF]

Access: concern I see personal introduction, or direct click me free to receive

For face questions byte beating finishing, classified, step by step, from basic to in-depth, from easy to Jane.

The content of the discussion into five chapters, basic computer face questions, questions surface data structures and algorithms, Java interview questions, Android interview questions, interview questions other extensions, a total of five non-technical questions section 354.

Each issue is accompanied by a reference standard answer is trial and error digestion (really spent a lot of time), it feels good to write articles as the answer.

Save time we all go to the search, time spent on the right things. .

Also finishing a full set of resume writing, spring recruit confused, HR interview and other issues to resolve reference suggestions are benefits to others.

Published 168 original articles · won praise 71 · views 20000 +

Guess you like

Origin blog.csdn.net/Aerfa789/article/details/105080771