The difference between Android resident and non-resident broadcasts, and the ListView Optimizer, the basic knowledge of Android novice consolidation

Source: Internet
Author: User

< Span style= "Color:rgb (50,62,50); font-size:10.5pt; Font-family: >1. Resident broadcast
Span style= "Color:rgb (50,62,50); font-size:10.5pt; font-family: Arial ">  resident broadcast, when your application is closed, if there is broadcast information coming, the broadcast receiver that you write is equally acceptable,
  His way of registering is to register with the Androidmanifast.xml in your application. Generally speaking this way is statically registered
 " Below is the configuration example

2<receiver android:name= ". Widgets. Deskwidgeweather ">   3<meta-data android:name=" Android.appwidget.provider "android:resource=" @xml/widget _weather_provider "/>   4<intent-filter>   5 <action android:name=" Android.appwidget.action.APPWIDGET_UPDATE "/>   6 <action android:name=" Action_weather "/>   7</ Intent-filter>   8lt;/receiver>  

< Span style= "Color:rgb (50,62,50); font-size:10.5pt; Font-family: >2. Very resident broadcast
   when the application is over, the broadcast is gone, For example, you register the broadcast receiver
   unloads the broadcast receiver in Ondestory. So your broadcast receiver is a very standing type. This is also called dynamic registration.
   such as write a listening sdcard status of the broadcast receiver

9SdcardStateChanageReceiver Sdcardstatereceiver; [email protected] 11protected void OnCreate (Bundle savedinstancestate) 12{super.oncreate (savedinstancestate)   ;   Intentfilter filter = new Intentfilter ();   Filter.addaction (intent.action_media_removed);   Filter.addaction (Intent.action_media_eject);   Filter.addaction (intent.action_media_mounted);   Filter.adddatascheme ("file");    Sdcardstatereceiver = new Sdcardstatechanagereceiver ();   Registerreceiver (Sdcardstatereceiver,filter);   [email protected] 23protected void OnDestroy () {unregisterreceiver (sdcardstatereceiver); 26class Sdcardstatechanagereceiver extends broadcastreceiver{@Override public void OnReceive (Context   Context, Intent Intent) {state=android.os.environment.getexternalstoragestate String (); System.out.println ("SDcard changes!   Status: "+state);   //checksdcard (); Checksdcard () {State=android.os String.Environment.getexternalstoragestate ();   Panax Notoginseng System.out.println (state); if (state.equals (Android.os.Environment.MEDIA_REMOVED) | | state. Equals (Android.os.Environment.MEDIA_UNMOUNTED))   {System.out.println ("SDcard uninstalled!");  40} 41} 42}

One of the ListView optimization methods


Write a viewholder inner class to put in the view that needs to be reused, viewholder tag to mark these view

Content provider how to send information

Use a Intent Intent Putextra () method to add the message, register a broadcastrecriver to receive the message, and update the information in the activity

What kinds of Android life cycle do you have?

1. foreground process. Such a process has an activity that is displayed on the screen and interacts with the user or one of its intentreciver is running. Such programs are of the highest importance, and only when the system is very low in memory will it end up as a last resort.
2. visible process. Programs that are displayed on the screen but are not in the foreground. For example, a foreground process appears in front of the process as a dialog box. Such processes are also important, and they will only be ended if the system does not have enough memory to run all foreground processes.
3. service process. Such processes continue to run in the background, such as background music playback, background data upload and download. Such a process is generally useful to the user, so it will be ended only if the system does not have enough memory to maintain all of the foreground and visible processes.
4. background process. Such a program has an activity that is invisible to the user . When the system is running out of memory, the program follows LRUthe order is ended.
5. empty process. Such a process does not contain any active program parts. The system may turn off such processes at any time.

Example diagram:


A lot of basic knowledge is our daily development used to get, do not neglect, in fact, sometimes they play a very important role, such as the ListView is our common

The difference between Android resident and non-resident broadcasts, and the ListView Optimizer, the basic knowledge of Android novice consolidation

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.