Android Application Development For Dummies Cheat Sheet - dummies
Cheat Sheet

Android Application Development For Dummies Cheat Sheet

From Android App Development For Dummies, 3rd Edition

By Michael Burton

Developing Android applications calls for familiarity with a development environment, an SDK, emulators, and the Android platform. Immersing yourself in the various screen sizes, framework intricacies, and dependencies can leave your head spinning. Here are some helpful hints to get you through your day-to-day development experience.

10 Helpful Hints for Android Application Development

Although solving problems with Android is a simple task, you may get to the point in app development where you’re not sure what to do. The following list should point you in the right direction when you’re in need of help.

  • Understand the Activity lifecycle and Fragment lifecycle.

    You will use them over and over, and a thorough understanding can help avoid baffling problems later.

  • Remember that you are responsible for saving and restoring instance states in activities and fragments.

    If you create a member variable in an activity or fragment, make sure you save it in onSaveInstanceState() and restore it using the Bundle in onCreate(). Failing to do so can make your activity or fragment appear to work most of the time, but randomly fail in other situations (such as when a user rotates their screen).

  • Not sure how to solve a particular problem?

    Visit the forums at 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.

    The Android Developer website provides a list of common tasks and instructions on how to perform them.

  • If you’re not sure what a package or class does, you can quickly identify its purpose.

    You can place your cursor over the object or class while inside Android Studio and press Ctrl+J to view the documentation pop-up window. If no tooltip exists, you can view the documentation online at Android Developer Reference.

  • You can quickly find all references of a particular object.

    You can do this in your class file by selecting the object and press Alt+F7.

  • You can make the stream messages in the logcat window more readable.

    You do so by creating a filter that specifically applies to your application logging. You may also find pidcat to be helpful.

  • Many errors have a quick fix.

    Go to the error and then press Alt+Enter to get the quick-fix menu. This can be a handy way to add new fields and methods. For example, you can type the name of a getter that does not yet exist, press Alt+Enter, and then choose Create Getter to have the method created for you automatically.

  • It’s easy to quickly navigate around a project.

    To do so, press Shift twice rapidly and start typing the name of the thing you’re interested in. It can be a file, type, member, local variable, or just about anything. Select it from the pop-up list and press Enter.

  • To quickly run your Android application, press Ctrl+R.

7 Android Studio Keyboard Shortcuts

You’ll most likely spend most of your Android development career in the Android Studio IDE. Here are a few keyboard shortcuts that can help you save a lot of time. More can be found by visiting Help → Default Keymap Reference.

Action Keyboard Shortcut
Create a new file in the current package Command+N (Mac) / Alt+Insert (Win)
Organize the import statements Ctrl+Alt+O
Navigate to the source definition Command+Click (Mac) / Windows+Click (Win)
Rename an object Shift+F6
Search through files Command+Shift+F (Mac) / Ctrl+Shift+F (Win)
Jump to a particular type or file Shift, Shift
Navigate left Command+Shift+[ (Mac) / Alt+Left (Win)
Navigate right Command+Shift+] (Mac) / Alt+Right (Win)

4 Common Android Intent Usages

You’ll use a few basic intents most of the time while developing mobile apps for Android. To save yourself some time, check out and remember the code for these several basic Android intents.

Intent Code
Start an activity startActivity(new Intent(this,
Create a chooser Intent.createChooser(yourIntent, “Please
Open the web browser Intent i = new
Start activity for a result startActivityForResult(yourIntent,

5 Tips for Developing Applications for Multiple Screen Sizes in Android

As a developer, you already know the importance of writing tests for your code. This is just as true for Android app development as it is for any other kind of development. Luckily, Android makes it easy to add tests to your app.

  • 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 Iconography guidelines.

  • When defining your user interface, try to always use the density-independent pixel (dip or dp) measurement unit for views and the scale-independent pixel (sip or sp) for font sizes.

    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 compatible-screens element to the AndroidManifest.xml file to help the Android market determine whether your application is compatible with various screen sizes.

    In general you should avoid compatible-screens, but sometimes it is necessary, such as when you are supplying multiple apks for different screen sizes.

  • Provide graphics for extra-extra-high-, extra-high-, high-, and medium-density devices.

    Although this may increase your development and design time, it greatly improves the usability and appearance of your application.

  • Use fragments liberally to make supporting tablet devices easier.