Book Image

Android Programming for Beginners - Second Edition

By : John Horton
Book Image

Android Programming for Beginners - Second Edition

By: John Horton

Overview of this book

Are you trying to start a career in programming, but haven't found the right way in? Do you have a great idea for an app, but don't know how to make it a reality? Or maybe you're just frustrated that in order to learn Android, you must know Java. If so, then this book is for you. This new and expanded second edition of Android Programming for Beginners will be your companion to create Android Pie applications from scratch. We will introduce you to all the fundamental concepts of programming in an Android context, from the basics of Java to working with the Android API. All examples use the up-to-date API classes, and are created from within Android Studio, the official Android development environment that helps supercharge your application development process. After this crash course, we'll dive deeper into Android programming and you'll learn how to create applications with a professional-standard UI through fragments and store your user's data with SQLite. In addition, you'll see how to make your apps multilingual, draw to the screen with a finger, and work with graphics, sound, and animations too. By the end of this book, you'll be ready to start building your own custom applications in Android and Java.
Table of Contents (35 chapters)
Android Programming for Beginners - Second Edition
Contributors
Preface
Other Books You May Enjoy
Index

Setting up Android Studio


Setting up Android Studio is quite straightforward, if a little time-consuming. Grab some refreshment and get started with the following steps:

  1. Visit developer.android.com/studio/index.html. Click the big green DOWNLOAD ANDROID STUDIO button to proceed:

  2. Accept the terms and conditions by checking the checkbox, and then click the big blue button DOWNLOAD ANDROID STUDIO FOR WINDOWS:

  3. When the download is complete, run the file you just downloaded. It has a name that starts android-studio-ide…, while the end of the name of the file will vary based on the current version at the time of reading.

  4. Click the Next > button to proceed:

  5. Leave the default options selected, as shown in the following screenshot, and click the Next > button:

  6. Next, we need to choose where to install Android Studio, as shown in the following screenshot:

The install wizard recommends 500 MB of free space, but you probably noticed from the previous screen that 2.1 GB was suggested. However, there are even more requirements later in the install process. Furthermore, it is much easier if you have all your Android Studio parts, as well as your project files, on the same hard drive.

For these reasons, I recommend having at least 4 GB of free space. If you need to switch drives to accommodate this, then use the Browse... button to browse to a suitable place on your hard drive.

Note

Note down the location you choose.

  1. When you are ready, click the Next > button.

  2. In this next window, you are choosing the folder in your start menu in which Android Studio will appear. Leave it at the default, as shown next:

  3. Click Install. This step might take some time, especially on older machines or if you have a slow internet connection. When this stage is done, you will see the following screen:

  4. Click Next >.

  5. Android Studio is now installed—kind of. Check the Start Android Studio checkbox and click the Finish button:

  6. You will be greeted with the Welcome screen, as shown in the following screenshot:

  7. Click the Next button.

  8. Choose Standard install type, as shown in the following screenshot:

  9. Click the Next button.

  10. Choose whichever color scheme looks nice to you. I chose IntelliJ, as shown in the following screenshot:

  11. Click Next.

  12. Now you will see the Verify Settings screen:

  13. Click the Finish button. Android Studio will now commence some more downloads, which could take some time.

  14. When Android Studio is ready, you will have the option to run Android Studio. At this point, click the Finish button. Android Studio is most likely ready. You can leave it open if you are carrying straight on with the next section, or you can close it and then reopen it when instructed in the next section.

Final step – for now

Using your preferred file manager software, perhaps Windows Explorer, create a folder called AndroidProjects. Make it at the root of the same drive where you installed Android Studio. So, if you installed Android Studio at C:/Program Files/Android, then create your new folder at C:/AndroidProjects.

Or, if you installed Android Studio at D:/Program Files/Android, then create your new folder at D:/AndroidProjects.

Note

Note that the screenshots in the next section show the AndroidProjects folder on the D: drive. This is because my C: drive is a bit full up. Either is fine. I did the install tutorial screen captures on a borrowed PC with plenty of space on the C: drive because that is the default for Android Studio. Keeping it on the same drive as the Android installation is neater and could avoid future problems, so do so if you can.

Notice that there is no space between the words Android and Projects, and that the first letter of both words is capitalized. The capitalization is for clarity and the lack of a space is required by Android Studio.

Android Studio and the supporting tools that we need are installed and ready to go. We are really close now to building our first app.

Now, let's look a little bit at the composition of an Android app.