Record Android fragmented knowledge points in the project for memo.
- Asyncqueryhandler
- Inheritance and handler, can be used to handle additions and deletions (data provided by ContentProvider)
- For example: query = new Asyncqueryhandler (Getcontentresolver ());
Include methods: Startquery, Startinsert, Startdelete, Startupdate:
Uri uri = sms.convesation_uri; query.startquery (nullnullnull, "Sms.date desc") ;
- Windowmanager.addview
<style name= "Anim_view" > //define <item name= "@android: Windowexitanimation" in the Anim folder >@ Anim/out</item> </style>
edittext=(EditText) Findviewbyid (r.id.txtbody); Edittext.setontouchlistener (new Ontouchlistener () { publicBoolean OnTouch (View V, motionevent event) { // turn off soft keyboard return False; }
-
- Block Input Method Popup when Eidttext (Focusable=false) is not in focus
Inputmethodmanager IMM =
(Inputmethodmanager) Getsystemservice (input_method_service); 0);
-
- If the input method is already displayed on the window, it is hidden, and the inverse is displayed
Imm.togglesoftinput (0,hide_not_always);
-
- Input method is single open
boolean isopen=imm.isactive (); // IsOpen returns True to indicate that the input method is open
- Handler's Removemessages
- Handler the removemessages (int) application, delete the message msg.what = Int. Usually used in conjunction with sendmessagedelayed. Scenarios: such as handling keystrokes frequently.
- ANR problem
Tip Application not responding,android prompts the user that the app is unresponsive, waiting, or terminating.
In Android, the responsiveness of the application is monitored by the activity Manager and the WindowManager system service. ANR is triggered when it detects the following conditions:
1. No events in response to input within 5 seconds
2.BroadcastReceiver did not complete in 10 seconds
The note here is to start a new service processing download, but the download task still has to be started separately because the service is also running on the main thread, which can cause the ANR problem.
- Service or Thread
The surface thread can do all of the service, and there is no problem blocking the UI. But for Android, the service priority
Higher than the background suspended activity, and the thread created by the activity. Therefore, as an important component of Android, it is used to perform background tasks.
- Application applications
- You can implement some initialization tasks for the entire app in OnCreate, which will only be executed once, such as broadcast monitoring
- The application life cycle is the application itself, so you can also save some global variables in application
- .9.png
- .9 types of images are a special image format for Android, which supports arbitrary stretching, which is not a simple pixel enlargement, but takes into account the contents of the picture
- The Draw9patch.bat tool can be made in Android.
Android Knowledge (ii)