It seems the next chapters in developer.android don’t really hold you by the hand as the first one where they guide you through building your first app. Instead they introduce you to the basics like managing activity lifecycles, supporting different devices, supporting different platform versions, building dynamic UIs, etc, but they only show you how to implement those specific things and provide you code snippets. What I need is more tutorials like the first one, where they show you everything.
I went to reddit/androiddev to see what people were using to learn android development. Someone referred TheNewBoston’s android videos. I checked them out. They are very good, at least the ones I’ve seen. He starts from scratch and the videos are never longer than 10 minutes each so each of them focuses on something specific. What is really good is that you can hear him explaining and at the same time showing you how to do it. If you don’t get something you can just rewind or look at the youtube comments. Most of the time if there’s a problem it gets pointed out in the comments.
By following his first 10 videos I was able to create a little app that adds 1 to a counter when you press a button. Simple, and the Java was easy, but I feel that I’m grasping the essentials more and more now.
Today has been a bit slow because I’m getting acquainted with all the new vocabulary, both from Java and the Android SDK. I’m still following the Android training from developer.android. I need to take my time to go over the methods and XML to really understand what each line does. I know most would just get the tutorial done as fast as they can to move on to more advanced things, but I’m doing this right now because I want to avoid “what did this thing do again?” or “what am I supposed to do here?”.
Following the tutorial, I created an input box with a button “Send” next to it. You input something (text) in that box and then hit send, which leads you to another screen or “activity” that will show you just what you wrote.
Simple? Not for your first time. The XML part was rather straight forward, you define the layout of the input box and button for your main activity (the app’s home screen). The tricky part starts when you have to link things to one another. On the XML button layout, you write onClick: and then the name of the method, which means it has to run when you click the button. This method needs to be defined in the .java file corresponding to that XML file. In this method, you put whatever you want do when you press that button. Then you have to link this method to the new class, which corresponds to the new activity. You do this by building a new “Intent” in the method, which is an object that can create new activities. In the new class which is invoked by the intent, you have to get the message which is located in the previous class. This is done by the intent object, in the previous class, you have to say to the intent object to carry/store the message. So you can retrieve this message and display it. And that’s it.
After that I started looking at the activity lifecycle and the different stages an activity can be at: created, started, resumed, paused, stopped and destroyed.
The first two happen really fast, usually when you click on an app, the activity gets created and started almost instantly. Then follows the resumed stage, which is when the activity is running and you as a user can use it. When it’s paused, the activity is partially visible and stopped is when it’s not visible. If the activity is paused then when you go back it resumes, when the activity is stopped and you go back, it’s restarted. Finally, destroyed is when you shut down the app completely.
As the first real post, I will be talking about my plans for the coming 30 days. Starting today, I will go on a journey to learn Android development. My goal after these 30 days is simple: Publish an app in the Play Store.
I don’t have much experience in programming. I started out last year with Python and have since then developed many small programs, mostly simple algorithms and small unfinished games. I have a good foundation of the basics otherwise I would not have been able to create my own 2D tile-based game, building the engine from scratch with Pygame.
Why android development? First of all, because I want to create something I would want to buy myself. Second, because I want that something to reach a target audience that likes my product. Android lets me put my app on the Play Store and that’s a great channel for reaching big audiences. I didn’t go iOS because of the restrictions (license and OSX) and because I myself own a Galaxy SII.
Day – 1
So far I’ve been able to set up my development environment and build my first app. I followed the guidelines from developer.android and installed the android SDK and eclipse with the ADT plugin for an optimal Android development environment. I created a project and ran my first app on my phone:
I must say it feels motivating to have such a fast time from setup to first app. Whenever I do any small changes and compile the code, it takes no less than 2-4 seconds for the app to run again on my phone. I feel this fast feedback is very important so that I don’t lose momentum. I have also set up the AVD (android virtual device) in order to test my future apps on different specs.