Five tips for Android programming: Activity, Service, BroadcastReceiver, ContentProvider, Intent

When I first came into contact with Android , I had no idea how to start . If I started directly from the SDK documentation, where did I start? If I was looking for examples on the Internet, what kind of examples should I look for to learn ? Two Both methods are fine. At that time, I followed a project, followed the project, and used the project to drive learning. This is actually a super good method, and it is also a fast way to learn. What if there is no project, you can set a task by yourself, and then make it, hehe, don’t worry, as long as you can think of it, just do it, even if you can’t do it even if you do all the experiments and search the website, then it proves Android It’s true that I can’t do it, and I’ll learn a lot from it. If you don’t believe me, you can try it (for example, I want to load the camera in vertical screen, but it turns out that it’s very difficult to do, or even impossible. That’s it, see : Android camera vertical screen research guide http://hi.baidu.com/juwend/blog/item/9977a8f69dff2229730eec6b.html  ).
  After a period of study, I have a deeper understanding of Android, we can follow the guidance of the Android SDK (official website: http://developer.android.com/guide/topics/fundamentals.html , local : local SDK/guide /topics/fundamentals.html) lists the five key categories of Android, that is, the Android application developmentThe starting direction is roughly divided into 5 large blocks, just as the title of this article writes——Activity application activities , Service background services, BroadcastReceiver broadcast reception, ContentProvider data support (external data), Intent intent (activity bridge), thank you here I was inspired by " Google  Android Development Introduction and Practice" (the book is quite expensive, the examples are relatively basic, and most of them revolve around the SDK, but the code format is not very standardized, it should be a problem caused by typesetting, the most valuable is the last part of the book A few project examples, I can learn a lot, I am very grateful to the author of the book for providing these things).
  Let's briefly talk about these 5 key blocks. For details, please refer to their respective documentation:
  1. Activity: application activity (official website: http://developer.android.com/reference/android/app/Activity.html  , Local: local SDK /reference/android/app/Activity.html )
  Activity almost undertakes all the operations of the user on the application ( Application), the Activity should have a window (Window), this window can be used through different themes (Theme) Changing appearance. Activity should pay attention to its life cycle (Lifecycle), the impact of device status (Configuration) changes, and the preservation of running status and data. This is in an applicationWhether it is reliable and humane is very important. Activity should also declare some permissions (Permissions) in order to use some software and hardware functions of Android. These declarations can be given by code or Manifest.xml. Finally, each Activity (entry) must be declared in the Manifest.
2. Service: background service (official website: http://developer.android.com/reference/android/app/Service.html  , local: local SDK /reference/android/app/Service.html )
  Service is a program without interface , it is a so-called service, also called a background program. You should pay great attention to the relationship between the two methods of starting the Service (startService) and binding (bindService) and the corresponding life cycle of the Service. The two methods of opening a Service account have different effects on the life cycle of the Service. There is also the declaration of permission and declaration of Service, which is also declared in the code or in the Manifest.
  3. BroadcastReceiver: broadcast reception (official website: http://developer.android.com/reference/android/content/BroadcastReceiver.html  , local: local SDK /reference/android/content/BroadcastReceiver.html )
  Broadcast reception is not the so-called radio broadcast, but refers to the intent (Intent) sent by sendBroadcast(), that is, the meaning of broadcast here is intent, and BroadcastReceiver can automatically monitor the pre-given The intent of the condition, if any, will notify the holder of this BroadcastReceiver.
  4. ContentProvider: data support (external data) (official website: http://developer.android.com/reference/android/content/ContentProvider.html  , local: local SDK /reference/android/content/ContentProvider.html )
  ContentProvider is It is used to save application data and establish a maintenance database so that the program can return to the previous state or save information when the program is restarted. Attention should be paid to the use of application permissions and the use of SQL language. Android uses SQLite, a lightweight database system .
  5. Intent: intent (active bridge) (official website: http://developer.android.com/reference/android/content/Intent.html  , local: local SDK /reference/android/content/Intent.html )
Intent is a very important component in Android application development. Many books use literal translation to explain it, which is not easy to understand. I think it can be translated as "activity bridge", which is a bridge connecting two activities. Through Intent, another arbitrary Activity can be started from one Activity, whether it is defined by itself or defined by the system. In ActivityGroup (extends Activity), the flag setting of Intent is very important for the startup method of sub-Activity.
  I think whether it is learning or development, it is better to start with these five key categories, which are clear, easy to grasp the key points, and will not cause problems. Of course, these 5 categories are just 5 aspects of Android application development, and there are many sub-categories that need to be studied. If you want to learn Android application development very well, you still have to study them Sub-wise, that's it.
Postscript: At the beginning, the project team gave two simple hot topics. One is to make a simple browser on the Android system. This thing is actually an example in the SDK document Hello View (the website on the official website: http: // developer.android.com/resources/tutorials/views/hello-webview.html  , and then the local address: local SDKdocsguide utorialsviewshello-webview.html, you can take a good look at the examples in Hello View when it is used, it is very useful), I didn’t know it at the time, so I searched and searched online, and the second was to create a simple chat room on the Android system, which involved issues between the server and the client (see PHP service setup: APMServ to set up a PHP server http:/ /hi.baidu.com/juwend/blog/item/48890045925be189b2b7dcb5.html ), I will write the specific reference code of the chat room in a future article. 
  Five Keys to Android Programming: Activity, Service, BroadcastReceiver, ContentProvider, Intent —— Juwend The author's level is limited, if there are any mistakes or omissions, welcome to correct, welcome to reprint and CV operation, but please indicate the source, thank you!

 

References:

http://bbs.iandroid.cn/android-9510-1-1.html

Guess you like

Origin blog.csdn.net/rsp19801226/article/details/7891852