Last week was hectic, we needed to reinstall and reconfigure the backend server of Perka’s File stash.
This week we will take a little twist and we will talk about a topic that is more focused on design: Screen sizes.
When designing Android apps the best practice is to use Density-independent pixel (dp) as measure. A dp is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a “medium” density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160).
Another best practice is to use wrap_content and fill_parent in XML so the layout will scale automagically. Also a RelativeLayout is a good practice, it will keep the distances the same even if the screen is bigger or smaller.
Also keep in mind of using layout and orientation qualifiers, which can be added to the /res/ directory. This will make it easy to make to make a different layout for another screen size and/or orientation.
For images used in for the different screens, you might want to use draw9patch to make image.9.png files. These files are processed by the tool and you can assign how it will be stretched.
Another good practice is to use Fragments, this will allow you to reuse designs in different layouts. You can combine the fragments in a layout or just use 1 fragment as layout.
A AsyncTask is a class that provides you an easy interface to create a new thread. It is recommended to use it by background tasks, like downloading through a internet connection.
From Honeycomb (SDK API level 11) it’s even mandatory to use Asynctask’s for internet connection downloads and if it’s not done it will force close the application. So it will be also for Ice Cream Sandwich.
Besides it’s mandatory it’s also really handy. You will take pressure from the UI Thread and it will be processed faster and parallel to the UI Thread.
Perka’s File Stash is updated with the: Flash zip option to flash CWM zips.
Long press on the zip file -> choose: Flash zip -> Wait untill it’s downloaded -> confirm the flash, if the file is already downloaded, just confirm the flash.