How To Use Android Developer Options Like A Pro
May 18, 2017
As a software developer, it is very easy to become so engrossed in mastering every nuance of a framework that we often tend to forget just how important it is to understand the subtleties of the hardware we deploy to. This is particularly true for Android developers, where device fragmentation poses the challenge of developing and deploying to a cavalcade of thousands of different devices. A developer who knows how to employ device Developer Options can alleviate much consternation in the development process. Unfortunately, many Android developers only use the Developer Options when they enable USB Debugging and disregard the treasure trove of tools available to them. So, let’s explore a few of my favorite Android Developer Options.
Wake up sleepy head
Enabling the Stay Awake Developer Options prevents the screen from dimming when it is plugged into a USB port. Having to constantly wake up the device during development can become pesky, so this is a good option to enable to maintain your sanity.
Respect the process
The Process Stats Developer Option can reveal whether or not your app is a memory glutton. If you are developing a project that implements background services such as geocoding, it is highly recommended to use this option as a standard practice in your development process.
Expect the unexpected
My favorite Developer Option is enabling Do Not Keep Activities. This option removes activities from the backstack as soon as a user leaves it; this is invaluable because it compels developers to ensure their code can handle occurrences such as removing an activity due to low memory. Oftentimes, this reveals a bug as minuscule as forgetting to implement onSaveInstanceState or something more sinister such as poor app architecture. In my experience, I have found it beneficial to have this Developer Option enabled at all times. It is also good practice to occasionally use the Limit Background Processes Developer Option to set the background process limit low or disable them altogether. Debugging an application without allowing background processes usually reveals critical flaws as well.
Cultivate an eye for UI
Rectifying layout issues can be tricky. However, by enabling the Show Layout Boundaries Developer Option, the boundaries for the views in your layouts will be highlighted to serve as a visual indicator. This is very useful when programmatically setting view dimensions for different screen densities.
Layout waste can be reduced by enabling Debug GPU Overdraw Developer Option. This will identify all the areas where the app is asking the device to draw a UI element on top of another UI element with a red overlay. Depending on the complexity of a view, overdraw can sometimes be impossible to avoid, but it is nice to be able to identify opportunities to use layout resources more efficiently.
Related: Striking a Balance with UI Tests
The Show Touches and Show Pointer Location Developer Options are also very helpful as they provide visual feedback and cues when a user interacts with a UI element in your app.
Arguably the coolest Android Developer Option is the Simulate Secondary Displays. This option essentially allows you visualize how your app will look on a device with another screen size via an overlay.
Stay in your lane
Enabling the Strict Mode Enabled Developer Option prevents the main thread from being abused by long, resource-intensive processes. This is an option that I recommend always be enabled, especially if your application makes several web requests. The Show CPU Usage Developer Options is also useful as it overlays a logcat detailing CPU usage in the upper-right corner of your device.
Much like the Show CPU Usage Developer Option, the Profile GPU Rendering provides immediate visual feedback on how hard the GPU is working to present a particular layout. This is a good tool to use in scenarios when you are trying to determine how taxing complex layouts and animations are on older devices.
Bring your passport
The Allow Mock Locations Developer Option is a necessity when developing location-based applications. When I enable this Developer Option, I use it in tandem with an application such as Fake GPS to deke my device into thinking I am somewhere I am not.
Android Developer Options protect us from implementation oversights, poor app architecture and just plain ol’ bad code. Implementing these tools into your standard development process will definitely give you an edge as a developer and improve your workflow.