Android Performance

Android Tips Round-Up, Part 1

Word count: 394Reading time: 2 min
2014/05/28
loading

With my recent project I’ve been posting one Android class/method a day. People have been asking for an archive of these links, so every couple weeks I’m going to round them up here. I’ll also be adding a bit of color commentary, but still the goal is for this not to be a ton of work for me. :)

Activity.startActivities() - Nice for launching to the middle of an app flow.

TextUtils.isEmpty() - Simple utility I use everywhere.

Html.fromHtml() - Quick method for formatting Html. It’s not particularly fast so I wouldn’t use it constantly (e.g., don’t use it just to bold part of a string - construct the Spannable manually instead), but it’s fine for rendering text obtained from the web.

TextView.setError() - Nice UI when validating user input.

Build.VERSION_CODES - Not only is it handy for routing code, it’s also summarizes behavioral differences between each version of Android.

Log.getStackTraceString() - Convenience utility for logging.

LayoutInflater.from() - Wraps the long-winded getSystemService() call in a simple utility.

ViewConfiguration.getScaledTouchSlop() - Using the values provided in ViewConfiguration ensures all touch interaction feels consistent across the OS.

PhoneNumberUtils.convertKeypadLettersToDigits - Makes handling phone number data a snap, as some companies provide them as letters.

Context.getCacheDir() - Use the cache dir for caching data. Simple enough but some don’t know it exists.

ArgbEvaluator - Transition from one color to another. As was pointed out by Chris Banes, this class creates a lot of autoboxing churn so it’d be better to just rip out the logic and run it yourself.

ContextThemeWrapper - Nice class for changing the theme of a Context on the fly.

Space - Lightweight View which skips drawing. Great for any situation that might require a placeholder.

ValueAnimator.reverse() - I love this for canceling animations smoothly.

More

  1. Part 1
  2. Part 2
  3. Part 3
  4. Part 4
  5. Part 5

Original Article: http://blog.danlew.net/2014/03/30/android-tips-round-up-part-1/

About Me && Blog

Below is my personal intro and related links. I look forward to exchanging ideas with fellow professionals. “When three walk together, one can always be my teacher!”

  1. Blogger Intro
  2. Blog Content Navigation: A guide for my blog content.
  3. Curated Excellent Blog Articles - Android Performance Optimization Must-Knows
  4. Android Performance Optimization Knowledge Planet

One walks faster alone, but a group walks further together.

Scan WeChat QR Code

CATALOG
  1. 1. More
  • About Me && Blog