Android Tablet Application Development For Dummies Cheat Sheet
If you’ve decided to develop applications for the Android platform, immersing yourself into the various screen sizes, framework intricacies, and dependencies can leave your head spinning; therefore, here are some helpful hints to get you through your day-to-day development experience.
Helpful Hints for Developing Andoid Apps
While solving problems with Android is a simple task, we all get to the point in which we’re not sure what to do. The list below should point you in the right direction if you need help designing your Android app.
Not sure how to solve a particular problem? Visit the forums at StackOverflow.com and use the Android tag. StackOverflow is an Android platform–recommended destination for developer questions.
The most common tasks have already been done for you. A list of common tasks and instructions on how to do them are provided by the Android developer Web site.
If you’re not sure what a package or class does, place your cursor over the object or class while inside Eclipse to view the documentation pop-up window. If no tool tip exists, you can view the documentation online at http://d.android.com/reference/classes.html.
To find all references of a particular object in your class file, select the object and press Ctrl+Shift+G.
To make the stream messages in the DDMS perspective more readable, create a filter that specifically applies to your application logging.
When typing into Eclipse, you sometimes know the name of the destination property, method, or class you’d like to create. However, it does not yet exist. Type the name in the component, Eclipse will inform you that the component cannot be found. Now select it, and press F2. This gives you a small pop-up window that allows you to create through the click of a button.
To quickly navigate around a class file, press Ctrl+O and start typing the name of the member you’re interested in. Select it from the pop-up list and press Enter.
To quickly navigate among the tabs in the Eclipse IDE, press Shift+Page Up or Shift+Page Down.
To quickly run your Android application, press Ctrl+Shift+F11.
Eclipse Keyboard Shortcuts
You’ll most likely spend most of your Android development career in the Eclipse IDE. The following table shows a few keyboard shortcuts that can help you save a lot of time.
|Create a new file in the current package||Alt+Shift+N|
|Organize the import statements||Ctrl+Shift+O|
|Navigate to the source definition||F3|
|Rename an object||Alt+Shift+R|
|Search through Java files||Ctrl+H|
|Open a particular type||Ctrl+Shift+T|
Common Android Intent Usage
An Intent object in Android is, well, exactly that: an intent. The best way to think about intents is to envision turning on a light with a light switch. Your intent is to turn on the light, and to do so, you perform the action of flipping the switch to the On position. In Android, this correlates to creating an instance of the Intent class with an Action in it specifying that the light is to be turned on. Although Android uses many different intents, a few are common enough that you’ll use them all the time when you’re developing apps. These are listed in the table below.
|Start an activity||startActivity(new Intent(this, Destination.class));|
|Create a chooser||Intent.createChooser(yourIntent, “Please Select”);|
|Open the Web browser||Intent i = new
|Start activity for a result||startActivityForResult(yourIntent, YOUR_REQUEST_CODE);|
Developing for Multiple Screen Sizes in Android
One of the challenges that you will encounter during your time as an Android developer is developing apps for multiple screen sizes. There are many things to keep in mind during your adventure into screen sizes. The list below should help keep you on track.
The size requirements for each icon in each density vary for each type of icon. You find launcher icons, menu icons, status bar icons, tab icons, and many more. They are all built differently for each screen density. When building these icons, reference the Android Icon Design Guidelines.
Try to always use the density-independent pixel (dip) measurement unit when defining your user interface. This helps your application scale to different devices. The density-independent pixel is a virtual pixel that scales proportionally for each given screen density.
Provide the supports-screens element to the AndroidManifest.xml file to help the Android market determine whether your application is compatible with various screen sizes.
Provide graphics for high-, medium-, and low-density devices. Although this may increase your development and design time, it will greatly improve the usability and appearance of your application.