This article is the author in the Android development practice in handy shorthand, record some small problems of the solution and notes, continuous updating.
The following is shorthand content, if there is not rigorous place, look at the small partners pointed out.
1.Module does not generate an R file, you can try to cancel a reference to the Module.
After canceling as, the project will be compiled again to see if R can be generated at this time.
2.Activity Theme Setting error, it appears:
Java.lang.classcastexception:android.widget.linearlayout$layoutparams
Cannot is cast to Com.android.internal.widget.actionbaroverlaylayout$layoutparams
At this point, you need to specify a system style with Actionbar for activity/application, or have the custom theme integrated with Actionbar
System style, of course, you can use the normal activity class instead of the activity subclass of Actionbar.
3.java.lang.illegalargumentexception:nan is not a valid double value as per JSON
Specification. To override the This behavior, use Gsonbuilder.
Serializespecialfloatingpointvalues () method.
When a module is referenced in 4.AndroidStudio, a resource with the same name in the module is replaced by a resource in the app.
This allows you to implement custom resources without modifying the module. Only string has been tried at this time.
5.Dagger environment Configuration (resolves a situation where the Dagger class cannot be generated): http://www.itnose.net/detail/6353446.html
http://stackoverflow.com/questions/29562347/how-do-i-configure-intellij-gradle-to-use-dagger-2-0
6.Android Touchdelegate can only extend the response range of one view in the same viewgroup.
7.Baidu Map V3.7 Mkofflinemap do not call the Destroy method after the download is complete (maybe Baidu is doing some aftercare after the download),
Otherwise, offline maps may not work properly. In addition, this version of the mkolupdateelement.status is always 1, unreliable ~
8.ART JNI, GC http://developer.android.com/guide/practices/verifying-apps-art.html
9.IDEA update JDK to 1.8 (From1.7), which appears when compiling code:
Error: (6) Java: Comment Not supported in-source 1.3
(Please use-source 5 or later to enable comments)
Open Project Structure and find project language level in the project bar, modified to 1.3 or later.
10. When portrait and landscape two layouts are written for activity, tag values are added to the layout file root node and read at run time to differentiate between portrait and landscape.
11. Open the app and use the ADB shell Dumpsys activity top To view information about the app activity or to get the package name.
12. When you start the Activity, set the Flag,intent.setflags (intent.flag_activity_new_task| Intent.flag_activity_clear_task) can be emptied backstack.
13.context.createpackagecontext (pkgname,flags) can create another application context based on the package name, provided the Shareuserid and signature of the two are the same, This will
Two applications will run in the same process, and the main application will have access to the resources and ClassLoader (Context.getClassloader.load (ClassName)) of the affiliate application. Installed on every APK program in the device, the Android system will give it
Assign a separate user space, where Android:shareuserid is the corresponding Linux user ID and creates a sandbox for it to prevent impact with other applications. User ID
Assigned when the application is installed on the device. With Shareduserid, multiple apk with the same userid can be configured to run in the same process, so the default is to access each other
It can also be configured to run in different processes while accessing the resources (images, databases, and files) of its APK data directory, just like accessing the data of this program.
14.Activity View Hierarchy: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0331/1608.html
15. Dynamic Loading mechanism: http://blog.csdn.net/jiangwei0910410003/article/details/17679823
16. Disadvantages of inheritance: When the Super method refers to a method that can be overridden by a quilt, the method also overrides the Quilt class (calling Super.method is not valid).
17.Android 6.0 file.mkdirs () is invalid because of permissions control, can dynamically request permission: http://stackoverflow.com/questions/32225506/ Android-6m-permission-issue-create-directory-not-working
18. Creating a Layoutinflater for a resources to inflate the layout in the resource requires extend Contextthemewrapper to implement a resourcescontext,
Then use Layoutinflater.from (Context). Cloneincontext (ResourceContext);
Clickable controls in 19.ListView item
20. Using navigator to navigate prevents activity from referencing each other, and writing in activity to get the intent that initiates it avoids defining the parameter key externally.
21. Use Android. R.id.content can get the root element of the activity.
22.Java inner and outer layers need to reference each other, no inner layer can directly use the outer or outer layer can be directly used to say.
23. Before Java7, switch can only support byte, short, char, int, or its corresponding wrapper class and enum type. In Java7, string is supported.
24. Solve the dynamic loading Surfaceview splash screen problem in two ways: one, GetWindow (). SetFormat (pixelformat.translucent); Two, add a in the layout
Invisible Surfaceview.
25. Use fragment.onactivitycreated () to retrieve the view and restore view state.
26.Android through Intent.setcomponent (new ComponentName (Pkgname,classname)) can start another apk activity;
Dexclassloader (String Dexpath, String optimizeddirectory, String LibraryPath, ClassLoader parent) can load code in execution jar/apk.
When the content in 27.ScrollView is not sufficient to fill the full screen, you need to add android:fillviewport= "true" to fill the ScrollView full screen.
28.APK Resource ID information is not placed in the Classes.dex, in the RESOURCES.ARSC?? see:http://blog.csdn.net/luoshengyang/article/details/8744683
and http://blog.csdn.net/luoshengyang/article/details/8806798
29.Android floating-point arithmetic: embedded processors typically do not support floating-point operations, and all operations on "float" and "double" are through software
Implemented. Some basic floating-point operations can take even a millisecond of time to complete. Even integers, some chips have hardware support for multiplication
Lack of support for division. In this case, the division and modulo operations of integers are also done by software. So when you're using a hash table
Or do a lot of math, be careful.
30.Git Clone only one branch: Git clone-b <branch> <repo>
31.Java 1.5 starts with support for static references, you can refer to static methods directly, omitting the need to write a class name when calling a static method. Use the import static <class>.* to introduce all static methods.
32.Android activity in Getapplicationcontext!=getbasecontext (), the latter is a re-created for each activity contextimpl,activity itself is a
Contextthemewrapper, it relies on Contextimpl to do the actual work.
33.Thread of Looper and Mainthread Mainlooper are directly new, essentially no difference, enabled Looper thread created handler can perform UI actions
, but if the operation takes too long (such as sleep>100ms), it is prone to crash (to be verified when the time-consuming operation is prone to crash).
34.activitymanager.getrunningtasks (1). Get (0). Topactivity () to get the activity componentname of the foreground app.
35. If the application context is used, the bindservice,service will be the same as the application life cycle, without being affected by the activity's life cycle. If you are using a
The context of the activity binds the service, and the service life cycle is affected by the activity (not the rest of the app's activity) and does not need to call Unbindservice.
36.Exception raised during Rendering:com/android/util/propertiesmap (Details), change the Render tool version in the render preview screen.
37.AndroidStudio Ignore Files:
. idea
. gradle
build/
Local.properties
*.iml
38.Android Cut the irregular picture (both the pure circle button) or the pure rule picture (pure circle, square?) ) cannot be done. 9 Stretching, made bitmapdrawable (<bitamp/>) can be solved.
39.Android Add the hover window display, need to use the application context, if it cannot be displayed on the top of all applications, you need to use the service?
40.SurfaceView black Screen: (1) GetWindow (). SetFormat (pixelformat.translucent);
Exclude fields when 41.Gson serialization: HTTP://WWW.TUICOOL.COM/ARTICLES/V2EIRQZ
42. Introduce an association table to correlate the relationships between the two tables.
When converting list<t> 43.Gson, you need to use new typetoken<list<string>> () {}.gettype (), paying special attention to the curly braces behind the typetoken.
44. Isolate user data in folders and place user data (including databases) under a folder with user information.
45.Android Unable to implement a suspend operation that does not affect the subsequent operation?
46. Using Wait () and notify () is generally to synchronize threads, but be aware that if the method being called does not open an asynchronous thread, it may return directly, at this time after the method call
The wait () used waits for an asynchronous callback to notify, but the callback has already occurred in the method stack, which causes the thread to wait. If an asynchronous thread is turned on, then wait () must wait until the notify arrives.
47.Java when using generics, it is supported to automatically name parameters with a generic type, as long as the generic parameter names are the same as the generic names (case-insensitive).
48.Sqlite query null field is NULL, query for fields that are not empty field is not null.
The 49.ImageView tint in XML and setcolorfilter can be used to color pictures, to change the colors of the icons, and to hide the drawing when using PorterDuff.Mode.CLEAR.
50.fileoutputstream.getchannel (). Lock () can obtain a filelock to lock the file.
51. Fix Gradle DSL method not found: ' Android () ': Delete Project's Build.gradle file: android{}. see:http://www.hloong.com/?p=100
When you have clickable elements in item 52.ListView, set the focusable and Focusableintouchmode properties of the clickable elements to false and set Android for the ListView: Descendantfocusability= "Blocksdescendants"
This allows the button and item to be clicked.
53.Root principle: http://www.myhack58.com/Article/html/3/92/2013/36574.htm
54.requestWindowFeature () is used to dynamically determine the properties of the window, and this behavior occurs before Setcontentview, so it must be set before Setcontentview. If request
Windowfeature (Window.feature_no_title), the Decorview in Window does not generate the Titleview part, but only the contentview part.
When using a custom view property in a 55.Android style, you can use the property name without adding any namespaces (such as ANDROID:XXX)
56.PopupWindow Click outside to disappear, just set background: setbackgrounddrawable (new bitmapdrawable ())
57.Sqlite cannot open another transaction in the transaction, otherwise the transaction operation is invalid.
58.new SimpleDateFormat ("yyyy-m-d hh:mm"). Format (date) can go to 0.
59.View after binding, removed from the View tree and added, the bound data is still valid.
60.EditText setting inputtype= "numbersigned" You can enter negative numbers.
<item name= "android:imeoptions" >flagNoExtractUi</item> can disable input method to open the new interface full-screen input
62.Sqlite Association query: SELECT a.*,b.name from Task as A, Project as B WHERE a.status<= ' 2 '
The type range returned by 63.adapter.getitemviewtype () should be (0,itemviewtypecount]
64.Fatal Signal (SIGSEGV), code 0, fault addr 0x61b6 in Tid 25110 (renderthread) related to hardware acceleration, avoid setting
View.setlayertype (View.layer_type_hardware, NULL), hardware acceleration can be disabled in manifest when a problem occurs: <android:hardwareaccelerated= "false ">
65.ndk_project_path=null, added in App/build.gradle android{}
Sourcesets.main {
Jni.srcdirs = []
Jnilibs.srcdir ' Src/main/libs '
}
can be resolved.
66. It is easy to overflow when calculating a large value, preferably converted to a large numeric type calculation: such as Long Expire_login =90* 24 * 60 * 60 * 1000 result is negative, should be changed to:
Long Expire_login =90l* 24 * 60 * 60 * 1000;
Immersive 67.fitsSystemWindows implementation: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/1122/3712.html
68.app:layout_behavior= "@string/bottom_sheet_behavior"
The ontrimmemory in 69.Application is used for system recovery memory, at which time some unimportant memory caches can be freed.
70.ImageView adjust to Image,user adjustviewbounds=true and maxwidth/maxheight of ImageView.
71.<item name= "Android:windowdrawssystembarbackgrounds" >false</item> controls whether the content is rendered below the bottom bar
72.Sqlite DISK IOERROR WRITE because of a temporary directory problem that can be resolved by setting it:
http://blog.csdn.net/u011453773/article/details/50731331
73.Android call system share: http://stackoverflow.com/questions/30518321/ on-android-m-how-to-configure-the-direct-share-capabilities-image-text-an/30721038#30721038
74. Get an ANDROID Contentview container that can be ID:Window.ID_ANDROID_CONTENT through it.
The hashcode of object in 75.Java returns the hash value of an int. By default, in Object
The Hashcode () returns the 32-bit JVM memory address of the object. That is, if the object does not override that party
method, the 32 of the corresponding object is returned as the JVM memory address. The Equals method returns a true two Objec
T should return the same hashcode. So the subclass of the general object is to think of the Equals method and Hashcode
method is either implemented at the same time or not implemented. This should be very close for key-value pairs when used
Key. When overriding Equals and hashcode, you can use the methods provided by the IDE to be safe and efficient. Reference:
HTTPS://WWW.OSCHINA.NET/QUESTION/82993_75533 also pay attention to the ORM situation.
76.collections.synchronizedxxx (), which is a synchronous lock on all incoming objects.
The 77.HASHMAP operation is all through the array to find the link header node, key for the hash after finding the array index.
Its containskey also through the hash of key to find the corresponding linked list header node, and then traverse, but containsvalue because do not know
Key, cannot hash to find index, so is the array in order to iterate through each list lookup, the efficiency is low.
78.AndroidStudio Compile Error: Error:java.lang.NullPointerException
(no error message), remove the. gradle file from the project directory and restart it.
79.GreenDao limitations: The inheritance relationship of the model cannot be compatible, and the fields of the parent class cannot be generated if the parent class and subclass have
Tables are built and there is no inheritance relationship between DAO. You might consider merging a table at this point.
The meaning of 80.serialVersionUID: http://lenjey.iteye.com/blog/513736
81.ScrollView nested GridView or ListView, you can override the Onmeasure method, set
The measurement height is the maximum, the measurement mode is At_most, and the following ScrollView scroll is realized. At this point, if
When the layout is automatically scrolled to the GridView location, the GridView focus can be disabled.
82.HttpUrlConnection appears eofexception, is said to be when the response InputStream is Gzipinputstream, will cause the HTTP HEAD conflict, here should be a bug, for reasons can refer to the following URL:
https://code.google.com/p/android/issues/detail?id=24672, you can set Connection.setrequestproperty ("Accept-encoding") by setting the , "") to resolve.
You cannot use view directly in the item layout of 83.RecyclerView, you need to use a specific view. Otherwise, Createviewfromtag Nullpointer may be reported.
84. In the method that returns the collection, it is not recommended to return NULL, but to return collections.emptyxxx.
The conversion of a subclass of a 85.List generic parameter to a parent class, you can first convert the class to be converted to a generic collection, and then assign a value to the recipient, such as A and B,
Where B extends A, you need to convert list<b> to list<a>, you can:
List list=list<b>;
List<a> receiver=list;
You can also directly
Use the List.class.cast () method, such as:
List<a> Receiver=list.class.cast (list<b>);
86.Seekbar sliders on the offset, together with MaxHeight and minheight can be resolved, they are used to specify the progress of the background height.
When the status of view in 87.AdapterView does not change (apply selector), it can be handled like a click Control, close Focusablity, plus focusblockdesendants.
88.PNG bitmap.compress compression quality is ignored when quality is used, it is recommended to use WEBP.
89. Four ways to set activity Jump animation: http://blog.csdn.net/qq_23547831/article/details/51821159
90.XListView needs to be set adapter to show Header,footer and pull up and down
A. Dex cannot parse version of byte code, required in the app Gradle android{...} Added in:
compileoptions {sourcecompatibility javaversion.version_1_8targetcompatibility JavaVersion.VERSION_1_8}
If there is Jack error, also need in defaultconfig{...} Add jackoptions {enabled true}
All methods in 92.collections.synchronizedlist are added synchronize (mutex) {...} synchronization, in addition to accessing the Iterater method, requires manual locking, see their implementation as follows:
Public Listiterator<e> Listiterator () {return// must be manually synched by user } public listiterator<e> listiterator (int index) {return// must is manually synched by user}
93. Use Gradle for Umeng channel packaging First you must change the following in Androidmanifest.xml Meta-data:
<meta-data android:name= "Umeng_channel" android:value= "${umeng_channel_value}"/>
Then add the productflavors {android{} to the build.gradle of the app.
--= [Umeng_channel_value:name]}}
Note that the channel name cannot begin with a number. You can also use a third-party packng package, but its channels are not written to manifest, and if two signatures result in loss.
94.Gradle read the Local.properties file, read the signature configuration information as follows
New= project.rootProject.file (' local.properties '). Newdatainputstream ();p roperties.load ( InputStream)// Read file def sdkdir = Properties.getproperty (' key.file ') storefile file (Sdkdir) // read field def key_keyalias = Properties.getproperty (' keyalias '= Properties.getproperty (' Keypassword '= Properties.getproperty (' Storepassword ' ); Storepassword Key_storepasswordkeyalias Key _keyaliaskeypassword Key_keypassword
0DP is accurate when 95.LinearLayout scale layout is not included with 0 weight.
96. Bitmap too large to being uploaded into a texture error occurs because after hardware acceleration is enabled, larger pictures cannot be displayed, solution three:
(1) android:hardwareaccelerated= "false" Turn off acceleration
(2) Compress when loading picture
(3) Split the large image into small pieces to load the display picture slices
Android Development Handy to remember