Shoppoke
Making Shopping on mobile damn easy.
Wednesday, July 30, 2014
Thursday, February 6, 2014
Android performance tips
These are some of the very basic android java programming tips.
- Don't do work that you don't need to do.
- Don't allocate memory if you can avoid it.
- If you have a method returning a string, and you know that its result will always be appended to a StringBuffer anyway, change your signature and implementation so that the function does the append directly, instead of creating a short-lived temporary object.
- An array of ints is a much better than an array of Integer objects, but this also generalizes to the fact that two parallel arrays of ints are also a lot more efficient than an array of (int,int) objects. The same goes for any combination of primitive types.
- If you need to implement a container that stores tuples of (Foo,Bar) objects, try to remember that two parallel Foo[] and Bar[] arrays are generally much better than a single array of custom (Foo,Bar) objects.
- Avoid creating short-term temporary objects if you can. Fewer objects created mean less-frequent garbage collection, which has a direct impact on user experience.
- If you don't need to access an object's fields, make your method static. Invocations will be about 15%-20%
- Avoid internal getters/setters.
- You should use the enhanced for loop by default, but consider a hand-written counted loop for performance-critical ArrayList iteration.
- Prefer double to float
- In order to improve the layout efficiency when you specify the weight, you should change the width of theEditText to be zero (0dp). Setting the width to zero improves layout performance because using"wrap_content" as the width requires the system to calculate a width that is ultimately irrelevant because the weight value requires another width calculation to fill the remaining space.
Also, Please install our android application to start poking stores, and provide your valuable feedback to us.
Cheers
Shoppoke Technology Team
Subscribe to:
Posts (Atom)