Skip to content

Beginning Android Resources

Nathan Esquenazi edited this page Aug 16, 2014 · 56 revisions

Attribution

This guide is not original content, instead this post is an amalgamation of numerous other guides discussing the process of learning Android. This guide currently incorporates content from the following list of sources:

High Level Guide

  • Installation - If you have never done Android development, first setup your Android environment by following these Android Setup Slides
  • Programming - If you are starting with no programming knowledge, we recommend you learn Java first (see resources in next section)
  • First App - Consider starting by building a simple todo app by following the slides. Alternately try this video tutorial that will guide you through the basics of an Android app. I recommend that you not only watch the video but repeat what he is doing simultaneously.
  • Finding Solutions - Learn how to search for solutions before you ask questions; check sources like StackOverflow and the cliffnotes for answers. Learn how to debug your code. This means using LogCat and reading stack traces, also learning how to use breakpoints.

Learning to Program with Java

If you never programmed at all before or if you are interested in starting with the basics, spend the first few months just on learning Java. Learn the syntax and understand how everything works. You’ll need to be able to create classes, create and call methods, use interfaces as well as know how inheritance works, before you can go to the next step. These are the basics of Java, and you’ll use them extensively when developing Android apps. Helpful resources for learning Java:

Be sure to check out these particular Java topics as well:

Understanding HTTP and APIs

In addition to understanding Java and OOP, most Android development requires the use of data from a server-side database and as such requires you to have a solid conceptual understanding of RESTful APIs, consuming HTTP endpoints and parsing JSON responses. Here are a few resources to get started:

You also need to know how to understand XML since a great deal of Android development takes place in XML files:

Once you understand Java, OOP (Classes, Inheritance, etc), XML and APIs with JSON, you now have the proper context to enter the world of Android development.

Practical Tips for Android Development

Understanding the concepts above is a good thing because it allows you search for practical ways to achieve something. Almost everything you can think of doing has already been tried and documented by someone else. You just need to know how to find it. Which leads me to my next set of things you may consider to learn first:

Speaking of Eclipse, the IDE most people still use to program for Android, whether you want to use it or not is up to you. Bear in mind the following though:

  • The alternative IDE most people talk about, Android Studio (which is based on IntelliJ), is still in an early access preview. The official Android page has the following warning about it: "Android Studio is currently available as an early access preview. Several features are either incomplete or not yet implemented and you may encounter bugs."
  • Most tutorials and documentation for beginners are still based on the use of Eclipse. All the resources I talk about here which are connected to an IDE, refer to Eclipse.

In terms of design resources check out:

Beginning Android Resources

With the basics in mind, it is time to start coding your first Android app. To begin, download and install the [Android Developer Tools] (http://developer.android.com/sdk/index.html). The Android SDK is actually a bundle of helpful tools consisting of Android libraries, emulator, debugger and documentation. It gives you a framework of Java classes and methods that all Android devices are able to use. The whole SDK is neatly packaged inside Eclipse or Android Studio, allowing you to only worry about your code and how devices implement it.

Android apps are a bit different from ordinary Java applications, because they’re build around Activities and Fragments, which both have lifecycles that determine the state of the app. When learning Android it’s not about learning how to code, it’s more about understanding the way Android works. That means that you’ll spend the majority of the time learning about Activity lifecycles, Fragments, ListViews, Bundles and other important Android concepts.

Consider starting with the following tutorials and resources:

  • The Android official training guides are a good place to start. The Building Your First App lesson is very easy to follow and already gives you a good understanding of some key concepts of the Android SDK.

  • The Android Development Tutorial by Derek Banas is great for those of you who prefer video lessons. It has 25 video lessons in total ranging from 10 to 30 minutes each. I used the first lessons to get a feel of the development process, specially to understand layouts.

  • CodePath Android Guides gives you even more explained code recipes and examples on how to build most common things in an Android app. I wish this was published when I started learning. It would have certainly helped.

  • Vogella Android Tutorials - Awesome free tutorials for most common Android topics. Great as a supplementary resource on top of these Android Cliffnotes.

  • Developing Android Apps by Google - Udacity course created by Google that teaches the core concepts involved in developing Android apps through videos and course work.

  • Programming Android Applications on Coursera - Coursera online course from the University of Maryland.

  • CodeLearn Android Tutorial - Interesting interactive tutorial for learning Android step-by-step. Definitely worth a look as you build a twitter client step-by-step.

  • Common tasks are a useful list of typical things you can do in your app and how to develop them.

  • Tasker is a great app available on the Google Play Store. You probably have heard of it. This app won't teach you anything about how to develop Android apps but it will show you what an Android app can do with your phone. I learned a lot from it. Whenever I realised I wanted to do something specific, I knew I could do it because I had done it before on Tasker.

  • Building Mobile Applications Course - Courseware including videos and slides with high-level overview of Android development.

  • DevAppsDirect is another great app you can get from the Play Store. While it also won't teach you how to develop an app, it will show you what is available out there. The app maintains a list of open source libraries you can use in your project for a variety of purposes. Knowing what you can reuse will save you a lot of time in the future.

  • Android Programming: Pushing the Limits is a solid book to check out.

  • The Busy Coder's Guide to Android Development is comprehensive with its over 2,400 pages but starts with the basics, explaining the concepts. It also has those "do-it-yourself" tutorials to help you retain what you are learning. The book is a bit expensive but it comes with a one-year subscription to keep it updated during the period.

All code examples are free and can be found here. Even if you don't buy the book, consider browsing through some of the examples there to learn how other programmers do things. Finally, Mark Murphy, the author of the book, is helpful whether you contact him by e-mail or on the StackOverflow website. Check out his profile. He is in the all time top-10 ranking list there.

Key Concepts

Configuration Changes

The most common of these is caused by orientation changes. Whenever there is an orientation change, your activity needs to be destroyed and recreated to address the changes in layout. This means you need to handle this recreation process yourself, making sure your app doesn't crash. A lot of beginners (myself included) consider simply disabling these changes but this is consider a bad practice. Besides, even if you do disable orientation changes, there are other things that can cause configuration changes that you need to handle anyway.

Here are two good posts discussing this further: http://stackoverflow.com/a/582585/362298 and http://stackoverflow.com/questions/1111980/how-to-handle-screen-orientation-change-when-progress-dialog-and-background-thre

To force yourself to catch problems sooner than later, consider the following tip from a previous post here on Reddit. You can enable a developer setting to not keep activities, so that they always get destroyed and recreated.

And more specifically, here are two examples of dealing with this problem when using a FragmentPagerAdapter, a common use case:

In a more abstract sense but still related to the topic, an old post on avoiding memory leaks is probably worthy of your time as well. This was written by Romain Guy, a Google employee very active in the Android community. It is certainly worth following him on Google+.

Parcelable

You can pass objects from one activity to another in a Bundle if your class implements the Parcelable interface. Parcelables were designed specifically for performance and should almost always be used instead of Serializable. Here is a good page explaining how to use it.

You can also have inheritance while using it without adding too much of an overhead to the children like this post

One thing you MUST always keep in mind is the order with which you write to the parcel and read from it. That order must be consistent. Otherwise you will start getting very crypt error messages which are very hard to debug.

Threading

Android is full of features to help you deal with threads. This is a very important aspect of Android development because your app has to give snappy responses. So all your heavy work such as database operations and network access need to be done in a separate thread.

For this reason it is important to know when to use a Service, a Thread, an IntentService or an AsyncTask. Learn about to them, check examples, and make sure you use them whenever appropriate. Perhaps the best place to start is this post summarizing your options: http://techtej.blogspot.com.es/2011/03/android-thread-constructspart-4.html You will realize that knowing about callbacks and listeners will be useful here too.

Broadcast Receivers

Broadcast receivers are a great way to have your asynchronous tasks (refer to the previous topic above) communicate with the main thread or to receive push notifications from your phone. It is a powerful feature to understand and use.

Consider reading about it in the official documentation. Also, refer again to the list of common tasks to get to know how to use them.

Compatibility

According to the latest statistics I can see in my Developer Console, API 9 and above represents almost 97% of all active Android devices out there. The number of Android tablets is still much lower than that of Android phones. Take this year's Q1 sales for a reference. 28 million Android tablets were sold as opposed to 156 million Android phones sold in the same period.

Supporting older Android versions turned out to be easier than I thought initially. I am using the ActionBarSherlock for providing the same UI experience in terms of ActionBar layout. I know now that the official Android Support Library has a similar library called ActionBarCompat which is probably worth considering to avoid relying too much on third-party libraries.

Aside from the ActionBarSherlock, though, most things in the UI can done to all API levels using the Support Library. You just have to make sure to use the right sets of classes. For example, instead of using "android.app.Fragment" when creating a new fragment, you use android.support.v4.app.Fragment instead.

Wrapping Up

Again please note this guide above was originally posted on reddit and was adapted here for wider access. For more details, check out the original document.

References

Finding these guides helpful?

We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.

Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.

Interested in ramping up on Android quickly?

(US Only) If you are an existing engineer with 2+ years of professional experience in software development and are serious about ramping up on Android quickly, be sure to apply for our free evening 8-week Android bootcamp.

We've trained over a thousand engineers from top companies including Apple, Twitter, Airbnb, Uber, and many others leveraging this program. The course is taught by Android experts from the industry and is specifically designed for existing engineers.

Not in the United States? Please fill out our application of interest form and we’ll notify you as classes become available in your area powered by local organizers.

Clone this wiki locally