Loadermanager use detailed (iv)---example: applistloader

Source: Internet
Author: User

Example: Applistloader
This article will be my fourth, and the last article in the series. Please tell me whether they are useful in the comments. The links to the previous articles are as follows:
One: Loaders before the worldSecond: Learn about Loadermanagerthree: Realize loadersFour: Example: Applistloader
at the request of the public, I have written a sample application that demonstrates how to implement a custom loader correctly. The app name is: Applistloader, which is a demo app that can query and tie out all installed apps on your Android device. The application has been modified, rebuilt (without bugs) in the Loadercustom.java example provided in API demos. The app uses Applistloader (subclasses of Asynctaskloader) to query the data and uses Loadermanager to manage loader content in the Activity/fragment declaration cycle.

Applistloader registered two Broadcastreceiver to monitor the system-wide broadcast that would affect the underlying data source (translator Note: The installation and uninstallation of the app will send broadcasts, both of which affect the data source we need to listen to, So this is the meaning of the sentence, translation good trouble). The new installation, update, and removal application is monitored by installedappobserver. Localization change (locale changed) is monitored by systemlocaleobserver. For example, when a user changes the language from English to Spanish, Systemlocaleobserver detects it and notifies Applistloader to requery the data so that the program can display the Spanish name for each app (if each app has a corresponding Spanish name). Click on the "Change Language" button and observe the loader's seamless response to the event (cool, isn't it!!) )。
when a Loader/loadermanager event occurs, the log information is displayed in the Logcat. So when analyzing logcat, remember to make sure the program is running. Hopefully it will be better for you to understand loader and loadermanager work together and understand the impact of activity/fragment life cycle on them. You can filter by using the app name "Com.adp.loadercustom" to get better results.


You can download the app from Google Play by clicking on the link below:

The source code is available on GitHub. Download, import into Eclipse and make any changes you want to make.
If this series of articles are useful, please leave your comments below and let me know. As always, please be free to ask questions.
Translator Note:two days of fragmented time translated four articles, a great harvest, at the same time feel loader and Loadermanager is not as difficult as imagined. The quality of the article is very high, if you have friends to know better Android related articles, please let me know, alone lele than the public lele.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.