In the original Chinese post, I translated Dan Lew’s fifth and final Android tips round-up, which he published in May 2014. As in the earlier parts, I added explanations and notes of my own rather than translating word for word. I hope a few of these tools save you some trouble. Technical corrections and version updates are noted below.
Technical review — 2026-10-13: Old Support Library links now point to AndroidX. Storage, thumbnail generation, and app languages have version-specific updates. The side effects of clearing app data and yielding a database transaction are explained in their entries.
ViewDragHelper — Helps custom ViewGroups implement child dragging and settling; use the androidx.customview.widget version. AndroidX DrawerLayout is a useful reference. The container must still connect touch handling and callbacks; constructing a helper alone does not make every View draggable. Flavien Laurent’s original article is retained as a historical link; it could not be reopened during this review.
PopupWindow — Displays temporary floating content above the current Activity. It attaches to an existing window; avoiding a new Activity does not turn it into a system overlay that may cover arbitrary apps. Configure focus, touch, and input-method behavior for the intended interaction.
ActionBar.getThemedContext() — Available since API 14, this provides the themed Context for custom Views placed in an ActionBar. Confirm that the page actually has an ActionBar before dereferencing getActionBar(); a no-action-bar theme does not supply one.
ThumbnailUtils — Available since API 8. The old createVideoThumbnail(String, int) was deprecated in API 29, which introduced createVideoThumbnail(File, Size, CancellationSignal). Use the File overload when direct file access is available; for provider-owned content Uris, consider ContentResolver.loadThumbnail(), also introduced in API 29. Run decoding and I/O off the UI thread and handle failure or cancellation.
Context.getExternalFilesDir() — Since API 8, this returns an app-specific external-storage directory whose contents are removed on uninstall. Access to your own directory needs no storage permission from Android 4.4 KitKat / API 19. External storage is not necessarily a removable SD card, and an unavailable volume can produce null. Android 10 introduced scoped storage; on Android 11 with target API 30+, WRITE_EXTERNAL_STORAGE grants no additional access. The old claim that permission lets an app write anywhere is obsolete. See Android 11 storage changes.
SparseArray — Saves memory for int keys by avoiding Integer boxing and per-entry HashMap objects. It uses arrays and binary search, so it is not faster for every operation and does not implement the general Map interface. Consider collection size and insertion/deletion patterns. SparseBooleanArray, SparseIntArray, and SparseLongArray store the corresponding primitive value types.
PackageManager.setComponentEnabledSetting() — Changes a manifest component’s enabled state; it does not start the component. Explicit enabled/disabled states override the original setting, while COMPONENT_ENABLED_STATE_DEFAULT restores the manifest setting. DONT_KILL_APP requests that the containing app not be killed, but component changes still affect behavior. Disabling a receiver does not necessarily stop all associated business work already in progress.
SQLiteDatabase.yieldIfContendedSafely() — When contention causes an actual yield, it ends the work so far as a successful transaction, then starts a new transaction that is not yet marked successful. It is not a pause that preserves one transaction’s atomicity. Do not use it arbitrarily inside a group of operations that must roll back together. Do not call setTransactionSuccessful() first, and do not use nested transactions here. The return value indicates whether a yield occurred.
Environment.getExternalStoragePublicDirectory() — Returns a File path for a public directory such as Pictures or Music, not permission to access it. The path API remains available in Android 16 source, but the old unrestricted-write assumptions do not apply to scoped storage. Prefer MediaStore for shared media, or the Storage Access Framework, available from API 19, for user-selected document locations. Keep internal app data in app-specific storage.
View.generateViewId() — From API 17, generates a runtime value suitable for setId() without colliding with build-generated R.id values. It does not detect manually duplicated assignments or provide a stable cross-process business identifier. Preserve the appropriate identity mapping when restoring View state across recreation.
ActivityManager.clearApplicationUserData() — From API 19, requests the equivalent of clearing the app’s storage in system settings. It removes private and app-specific external data, revokes related runtime permissions, and stops the app, while retaining the APK. See the Android 16 server implementation. A true return means the request was accepted. Ordinary logout should revoke sessions and remove the relevant tokens/account data according to product requirements, rather than indiscriminately deleting all local user content.
Context.createConfigurationContext() — From API 17, returns a new Context with resource configuration overrides, such as a locale used for selected resources. It does not change the entire app’s language in place. For app-level language preferences, Android 13 / API 33 provides LocaleManager; AppCompat 1.6.0+ offers AppCompatDelegate.setApplicationLocales() for older versions, with its documented Activity and persistence requirements. See the app-language guide.
ActivityOptions — From API 16, supplies Activity launch options such as custom animations; pass toBundle() to an appropriate launch overload. Use AndroidX ActivityOptionsCompat for compatibility, but not every new option has equivalent behavior on older systems. setLaunchDisplayId() was added in API 26 and remains subject to device capabilities and target-display access rules.
AdapterViewFlipper.fyiWillBeAdvancedByHostKThx() — This one earns a mention for the name alone. From API 11, AppWidgetHost uses it to announce that the host will call advance(), allowing the flipper to stop advancing itself. AOSP has other playful names such as GRAVITY_DEATH_STAR_I.
ViewParent.requestDisallowInterceptTouchEvent() — Requests that the parent and ancestors avoid onInterceptTouchEvent() for the current touch sequence. Parents should propagate and honor the request until UP / CANCEL. It cannot recover events already intercepted or bypass system gestures. The original touch-system talk is retained as a historical link; its contents could not be retrieved during this review.
More
Original Article: https://blog.danlew.net/2014/05/28/android-tips-round-up-part-5/
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!”
- Blogger Intro
- Blog Content Navigation: A guide for my blog content.
- Curated Excellent Blog Articles - Android Performance Optimization Must-Knows
- Android Performance Optimization Knowledge Planet: The paid community stopped operating in 2026 and no longer accepts new members; this link preserves its history.
One walks faster alone, but a group walks further together.
