1. Recently opened apps are not displayed in the recent Tasks list
Android:excludefromrecents= "true"
Set to true to exclude from the recent task list and not appear in the recent Tasks list
2. Determine whether a string str is null or is an empty string
Textutils.isempty (str)
3, the use of android:imeoptions= "Actionsearch|flagnofullscreen"
When doing a function to put EditText into Actionbar as the search box, setting the EditText property to Android:imeoptions= "Actionsearch", you will encounter a problem, when in the horizontal screen, The width of the edittext will be filled out on the screen except for the soft keyboard, and the requirements do not match, changed to android:imeoptions= "Actionsearch|flagnofullscreen" after the OK.
4. How to change the brightness of the picture
1, use Image.setcolorfilter (color.gray,porterduff.mode.multiply); You can darken the picture, then use Image.clearcolorfilter (), clear the filter, Revert to the original brightness;
2. Use
int brightness =-80;
ColorMatrix matrix = new ColorMatrix ();
Matrix.set (New float[] {1, 0, 0, 0, brightness, 0, 1, 0, 0,
Brightness, 0, 0, 1, 0, brightness, 0, 0, 0, 1, 0});
V.setcolorfilter (new Colormatrixcolorfilter (matrix));
But this method will make the color is not normal, the picture left a black edge;
5, use handler to realize the time interval event judgment
See the Gesturedetector.java in Android is determined by clicking and double clicking on the following code to implement the gesture:
public boolean ontouchevent (motionevent ev) {... case MotionEvent.ACTION_DOWN:if (mdoubletaplistener! = NULL) {Boolean hadtapmessage = Mhandler.hasmessages (TAP); if (hadtapmessage) mhandler.removemessages (TAP); if (mcurrentdownevent! = null) && (mpreviousupevent! = null) && hadtapmessage && Isconsidereddoubletap (mcurrentdownevent, mpreviousupevent, Ev)) {//This is a second tap Misdoubletapping = true; Give a callback with the first tap of the Double-tap handled |= Mdoubletaplistener.ondoubletap (mcurr Entdownevent); Give a callback with down event of the Double-tap handled |= mdoubletaplistener.ondoubletapevent (EV) ; } else {//This is a first tap mhandler.sendemptymessagedelayed (tap, Double_tap_tim Eout); } }......} Private Boolean Isconsidereddoubletap (Motionevent firstdown, motionevent firstup, motionevent seconddown) { if (!malwaysinbiggertapregion) {return false; } final Long deltatime = Seconddown.geteventtime ()-firstup.geteventtime (); if (Deltatime > Double_tap_timeout | | deltatime < double_tap_min_time) {return false; } int deltax = (int) firstdown.getx ()-(int) seconddown.getx (); int deltay = (int) firstdown.gety ()-(int) seconddown.gety (); Return (DeltaX * deltax + deltay * DeltaY < Mdoubletapslopsquare); } private class Gesturehandler extends Handler {Gesturehandler () {super (); } gesturehandler (Handler Handler) {super (Handler.getlooper ()); } @Override public void Handlemessage (Message msg) {switch (msg.what) {case Show_pre SS:mListener.onShOwpress (mcurrentdownevent); Break Case Long_press:dispatchlongpress (); Break Case TAP://If the user's finger is still down, does not count it as a tap If (mdoubletaplist Ener! = null) {if (!mstilldown) {mdoubletaplistener.onsingletapconfirmed (Mcurr Entdownevent); } else {Mdeferconfirmsingletap = true; }} break; Default:throw new RuntimeException ("Unknown message" + msg); Never}}
Specific can refer to the source code, here is the use of mhandler.sendemptymessagedelayed, if in double_tap_timeout time Mhandler the TAP message sent out, is the click Time, If it is not sent at this time, it is a double-click event.
Common knowledge of Android application development