2. Settings.System.getInt (CONTENTRESOLVERCR, String name, int def) method removes the parameter value of the parameter named name from the collection of system settings (Settings) parameters, If the parameter is not in the system settings, the default value of DEF is returned.
3. Activity's function Setvolumecontrolstream (Intstreamtype) is used to set the audio stream controlled by the volume Control key in the activity, which is generally set in the OnCreate () function. Among them, Streamtype is the type of volume that needs to be adjusted, in the following ways:
Audiomanager.stream_music media volume, i.e. audio and video volume
audiomanager.stream_ring Phone Ringtone Volume
Audiomanager.stream_alarm Phone Alarm Volume
Audiomanager.stream_notification the status bar at the top of the window notifies the amount of sound
Audiomanager.stream_system System Sound Volume
Audiomanager.stream_voicecall the volume of the call sound
AUDIOMANAGER.STREAM_DTMF Dual-tone dual-frequency volume
4. Role of public Intent registerreceiver (Broadcastreceiverreceiver, Intentfilter filter):
Resgister Abroadcastrecevier to is run in the main activity thread. The receiver would becalled with any broadcast Intent this matches the filter in the MainApplication thread.
5. Use of the Boolean android.app.Activity.isFinishing () function:
Check to seewhether this activity are in the process of finishing, either because you calledfinish () on it or some One else has requestedthat it finished. This was often used inonPause ()to determine whether the activity was simply pausing or completely finishing. Ifthe activity is finishing, returns true; else return FALSE.
6. Introduction to the Java.lang.ref.WeakReference class
When writing a Java program, you want to get information about an object at any time, such as when an object is reclaimed by the garbage collection mechanism, you can use weak Reference, but you cannot use Reference, and if you use Reference, the object will never be purged. However, using weak reference is able to obtain information about the object at any time, but does not affect garbage collection of the object. Examples of how to use:
A obj= Newa ();
weakreferencewr= new WeakReference (obj);
obj= null;
...
The Obj object is garbage collected for a period of time
If (Wr.get () ==null) {
System.out.println ("obj has been cleared");
}else{
System.out.println ("obj was not cleared");
}
Gets the object that the WeakReference refers to by using the Get () method.
7. The view.setvisibility () parameter has three different values:
View.visible The view is visible
View.invisible The view is not visible, but it still retains its position in ViewGroup without re-layout
View.gone The view is not visible, but it does not retain the position in the ViewGroup, re-layout, the following view will replace its location
8. Android:cachecolorhint properties and Android:listselector properties of the ListView
The default background of the ListView is the same transparent color as the system window, and if the ListView is added or the background color, the ListView will be black when scrolling,
Because, when scrolling in the list of view redraw, with the system is still the default transparent color, the color value is #ff191919. To change this situation,
Simply call the ListView setcachecolorhint (0), the color value is set to 0, or the properties of the ListView in the XML file android:cachecolorhint=
"#00000000". This way, there is no background color when scrolling to redraw the view.
When you click the item in the ListView is I, the selected item is displayed by default as an orange background. If you need to remove this effect, you can use the property Android:listselector property. If set to Android:listselector= "#00000000" or android:listselector=
@android: Color/transparent, there will be no behavior when you click on the ListView item.
9. Android Unit PX, Dip (DP), SP, DPI Introduction
PX (pixels): pixels, which is the actual pixel point unit on the screen. This unit is generally not used.
DIP/DP (device independent pixels): devices independent pixels, regardless of device screen
SP (scaled pixels): Similar to DP, mainly used to handle font size
DPI (dot per inch): screen pixel density, the number of pixels per inch. The larger the value, the higher the fineness of the screen, and the clearer the screen looks.
Use of @Override
@Override is pseudo-code, which means rewriting (and of course not writing), but the following benefits are written:
Can be used as a comment, easy to read
The compiler can verify that the method name below @override is in your parent class. If not, then the error
TouchEvent processing mechanism of Android system: Each view subclass of Android system has the following three related to TouchEvent processing
Method of:
Public booleandispatchtouchevent (motionevent ev): Used to distribute TouchEvent, the motionevent can record the coordinates of the trigger point
Public booleanonintercepttouchevent (motionevent ev): Used to intercept touchevent
Public booleanontouchevent (motionevent ev): Used to handle touchevent events
When touchevent occurs, activity first passes the touchevent to the topmost view,touchevent first to reach the dispatchtouchevent of the topmost view, The touchevent is then distributed by the Dispatchtouchevent, and if Dispatchtouchevent returns True, the ontouchevent processing of the view is given, If Dispatchtouchevent returns False, the Intercepttouchevent method of the view is given to determine whether to intercept the event, and if the Intercepttouchevent returns True, It is handed to its ontouchevent, and if it returns false, it is passed to the child view, and the dispatchtouchevent of the sub-view begins the distribution of the event. If the event is passed to the ontouchevent of a child view of a layer, the method returns False, and the event is passed from the view, and is received by the ontouchevent. If the ontouchevent passed to the top also returns false, the event disappears and the next event is not received.
Introduction to activity.finish ()
This method is called when the activity is completed, or when the activity needs to be closed. When this method is used, the system moves the topmost activity out of the task stack, but does not call the Ondestory () method in time, so its resources are not released in a timely manner. Because the stack is moved out, you won't find the activity when you click on the "Back" button on the phone.
the difference between androidwebviewclient and webchromeclient
webviewclient: Mainly used to help WebView handle various notifications, request events. such as: Onloadresource,onpagestart, Onpagefinish, Onreceiveerror, onreceivedhttpauthrequest
Webchromeclient: Mainly used for auxiliary webview Processing JavaScript dialog box, website title, loading progress and so on. such as: Onclosewindow (Close WebView), Oncreatewindow,onjsalert (WebView on alert invalid, need to customize Webchromeclient processing popup), Onjsprompt, Onjsconfirm,onprogresschanged, Onreceivedicon, Onreceivedtitle and so on.
When actually used, if WebView is only used to deal with some HTML page content, only with webviewclient, if you need more rich processing
Effects, such as JS, progress bar, etc., will be used to webchromeclient.
WeakReference class
WeakReference weakref = new WeakReference (ref);
This weakref is a weakreference that ref points to the object. You can use the Get method to refer to the object that the WeakReference points to. Put the object's weak reference into the Hashtable or cache, and the object can be reclaimed by the garbage collector when no strong reference points to them. In fact, there is a weakhashmap that specializes in doing this. Once weakreference returns null using the Get method, the object it points to has become garbage, and the Weakref object is useless. This will require some cleanup work. The Referencequeue class is doing this, and if you pass a WeakReference constructor to the Referencequeue class, the referenced object is automatically inserted into the reference queue when the referenced object becomes garbage. You can process this queue within a certain time interval.
Viewstub Components
The Viewstub component is a hidden, memory-intensive view object that can delay loading a layout resource file at run time. This layout resource file is loaded when viewstub is visible, or when the inflate () function is called. The viewstub replaces itself in the parent container when the view is loaded. Therefore, viewstub is always present in the view until setvisibility (int) or inflate () is called. The layout parameters of the viewstub are added to the Viewstub parent container along with the number of views loaded. Similarly, you can also define or rename the ID value of the View object to be loaded by using the Inflatedid property. When inflate () is called, the viewstub loaded view overrides and returns the View object. This allows the application to get a reference to the load view without additional execution of Findviewbyid ().
As follows:
1). There is a viewstub layout between Buttonone and buttontwo, such as:
2). When you click Buttonone, the layout in the viewstub is rendered, such as:
Android Learning Notes (iv)