In the original Chinese post, I translated Dan Lew’s third Android tips round-up, which he published in April 2014. As with the earlier parts, I added my own notes and explanations where I thought they would help. Some of these are tools I use myself; if a few are new to you, I hope they come in handy. The API corrections and version limits are noted below.
Technical review — 2026-10-13: Platform
android.app.Fragmentwas deprecated in API 28; the Fragment entries below use AndroidX. LocalBroadcastManager and Otto are no longer maintained. Other tips remain useful within the API and behavior limits stated below.
UrlQuerySanitizer — Parses URL query parameters and processes values using configured ValueSanitizer rules. It does not validate an entire URL or establish that its destination is safe. Check the scheme, host, and business fields for the intended use, and decide how unregistered and repeated parameters should be handled.
Fragment.setArguments() — Put saveable initialization parameters in a Bundle, usually after constructing the Fragment instance and before adding it to FragmentManager. Arguments can be restored across destruction and recreation. The default restoration path uses a no-argument constructor; AndroidX Fragment 1.1.0 introduced FragmentFactory for custom instantiation. Parameterized constructors are therefore not categorically forbidden, but the factory must also handle restoration.
DialogFragment.setShowsDialog() — A DialogFragment can appear as a dialog or embedded content. Setting this to false suppresses the Dialog; configure it before the UI is created and provide embedded content through onCreateView(). A layout created only inside onCreateDialog() does not automatically become the embedded Fragment’s View.
FragmentManager.enableDebugLogging() — This logging switch was deprecated in AndroidX Fragment 1.2.0. For debugging, the documented replacement is adb shell setprop log.tag.FragmentManager VERBOSE, followed by inspecting Logcat.
LocalBroadcastManager — The old process-local Intent dispatcher was fully deprecated in 1.1.0 (2022), with no further releases planned. Choose LiveData or reactive streams according to data ownership and observer lifetimes. The original alternative, Otto 1.3.8, is also deprecated and archived. A process-local event bus does not provide interprocess communication.
PhoneNumberUtils.formatNumber() — Formats telephone numbers, not general numeric values. The single-String overload was deprecated in API 21, which added formatNumber(phoneNumber, defaultCountryIso) for a default country/region such as CN. Handle a possible null result with an appropriate display fallback. Formatting does not prove that a number exists.
Region.op() — Performs region intersection, union, difference, and related operations. For overlap, compute INTERSECT into a result Region and inspect whether it is empty. Paths must first be converted with a clip via setPath(), which produces a non-antialiased pixel region rather than an exact floating-point path intersection. op() mutates the result receiver.
Application.registerActivityLifecycleCallbacks() — Available since API 14 for observing Activity lifecycle events within the app process, not for monitoring every app on the device. Unregister short-lived observers when finished and avoid retaining destroyed Activities in callbacks.
versionNameSuffix — Android Gradle Plugin can append a version-name suffix by build type or product flavor, such as -SNAPSHOT for debug builds. It does not change versionCode or installation identity. To install debug and release variants alongside each other, use distinct application IDs, for example through applicationIdSuffix.
CursorJoiner — A SQL join works when the data is in one database. What if it comes from two separate ContentProviders? CursorJoiner can compare the two Cursors. Both must already be sorted by the specified key columns in ascending order, with unique key tuples on each side. Results are LEFT, RIGHT, or BOTH; this does not create a new SQL result table or implement an arbitrary many-to-many join.
Genymotion — Dan Lew wrote that he used it all day and found it much faster. It still offers desktop and cloud products, but that was his experience at the time, not a fixed comparison with today’s Android Emulator. Compare under equivalent host, virtualization, image-architecture, and workload conditions.
-nodpi — Bitmaps in a directory such as res/drawable-nodpi/ are not automatically scaled to match device density. This does not control assets/, disable dp / sp conversion, or fix the entire layout to pixel dimensions. ImageView sizing and scaleType can still scale the displayed image; nodpi does not guarantee equal visual size across devices.
BroadcastReceiver.setDebugUnregister() — Enable it before registering a receiver to retain a later unregister call’s stack for diagnosing an incorrect subsequent unregister. It retains that information for the process lifetime and causes a leak itself, so it is a debugging aid rather than a production leak-prevention mechanism.
Activity.recreate() — Available since API 11, this requests a new Activity instance and is useful for checking restoration. It does not restart the process or automatically preserve all business state. Follow the lifecycle state-saving contract.
PackageManager.checkSignatures() — Compares package signing identities; check specifically for SIGNATURE_MATCH. This is not merely an installed-app query. A package name alone does not establish trust, and Android also checks signing compatibility during installation and updates. The original warning should not be read as allowing differently signed apps with the same package name to coexist or overwrite each other freely. Authorization still needs a trusted identity as the comparison baseline and must handle unknown packages and mismatches.
More
Original Article: https://blog.danlew.net/2014/04/28/android-tips-round-up-part-3/
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.
