Android resident with very resident broadcast difference, and ListView Optimizer, Android novice basic knowledge consolidation

Source: Internet
Author: User

1. Resident Broadcasting
Resident broadcasts, when your application is closed, assume that there is a broadcast message coming, the same can be accepted by the broadcast receiver that you write.
His way of doing this is by Androidmanifast.xml in your application.

The usual way to say this is static.
The following is a sample 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 will be gone, For example, you register the broadcast receiver
   Uninstall the broadcast receiver in the ondestory. So your radio receiver is a very standing type.

This is also called dynamic register.
   for example write a listening sdcard status 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 messages

Use a Intent Intent Putextra () method to add the message. Register a Broadcastrecriver receive a message and update the information in the activity

What kinds of Android life cycle do you have?

1. foreground process. This process has an activity that is displayed on the screen and interacts with the user or one of its intentreciver is executing. This procedure is of the highest importance. Only in the system memory is very low, as a last resort will be ended.


2. visible process.

The program is displayed on the screen, but not in the foreground. For example, a foreground process appears in front of the process as a dialog box.

This process is also very important, and they only end up when the system does not have enough memory to perform all the foreground processes.
3. service process. This process continues to execute in the background, such as background music playback, background data upload and download.

This process is generally very useful for users. So there is only when the system does not have enough memory to maintain the full foreground and visible processes. will be ended.


4. background process. This program has an activity that is invisible to the user .

This program is not running out of system memory. is ended in the order of LRU.


5. empty process. This process does not include program parts for whatever activity. The system may turn off such processes at any time.

Demo Sample diagram:


A lot of basic knowledge is used in our daily development. Don't neglect it. In fact, sometimes they are very critical data, for example, a ListView is something we often use.

Android resident with very resident broadcast difference, and ListView Optimizer, Android novice basic knowledge 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.