Required hardware and an open-source project
For the Buendia medical records system project, we’re building an Android tablet app that’s capable of displaying and modifying electronic records out in the field. So far, we’ve been targeting the Sony Xperia Z2 tablets as our reference platform - they’re a great size, they’re really light and they’re waterproof.
The project is open-source, and we’re finding that we have contributors who want to help, but don’t have a tablet device to test on. We’ve had developers use the Android emulator before, but emulation can be quite resource-intensive. Even if you’ve enabled HAXM (it’s a huge speed-up if your processor supports it!), the emulator still uses a couple of GB of RAM, which, in combination with Android Studio, can push even modern hardware pretty hard!
Whilst not everyone has an Android tablet, lots of our developers have Android phones, and want to use them for running the app, even though we’re not planning on supporting phones currently. It turns out you can tell Android’s Window Manager to use whatever resolution you want, and using this, we’re able to help developers be just a little more productive without the Android tablet.
Faking the resolution
Here’s how to do it:
- Make sure you have the Android SDK or Android Studio setup, and you can connect to your Android device using USB Debugging Mode.
- Run the following commands in a terminal. These values are for a Sony Xperia Z2 tablet, but you can substitute them for other values:
A few notes:
- It’s important to reboot after you’ve changed the density. Most apps don’t know how to deal with changes in density, and so most images and layouts will have bits that are too big or too small unless you reboot.
- You might need to swap the
1200x1920depending on the default orientation of your device.
- This setting persists until you change it back explicitly; you might want to bookmark this page ;)
- I tested this on a Nexus 5 running Lollipop; it might not work on older versions of Android.
Setting it back
These settings will persist until you reset them manually, so make sure to run this when you’re done and want your phone back to normal:
That’s it! Feel free to drop me a note and let me know if this works on your device.