Click here to Skip to main content
15,867,453 members
Articles / Mobile Apps / Android

Beginning Android Development – Part 2/3

Rate me:
Please Sign up or sign in to vote.
4.20/5 (4 votes)
20 Nov 2015CPOL12 min read 6.3K   2  
Beginning Android Development – Part 2/3

In part 1 of this three part series, we examined the exciting world of Android development career, beginning with this post I will start to introduce the fundamentals of Android development. The fundamentals we will cover are the Activity, Fragment, Intents, Layout, Shared Preference, ListView, Adapter and just enough Java. Don’t worry if you do not know what any of those terms mean, at the end of next post you will have a better understanding of not only what those terms mean but where they fit into in Android development. These are the concepts that I believe that you need to grasp to embark on this exciting journey as an Android developer.

Core Android Concepts and their Meaning

  • Activity - The Activity is at the center of Android development, it is a defined task that you want to accomplish. Making a phone call is an Activity, sending an email is an Activity, displaying a list of all countries in the world is an Activity. Another way to understand an Activity is to think of it as a window or web page. You are reading this article on a web page, that can be likened to an Activity. If you click on any link within this page then you can leave this web page or Activity and go to another web page which could be an unrelated web page in a different website. The same applies to Activity, you go from one Activity to another which could be a different app to accomplish tasks, this gives the illusion of an "app" while in reality it is a coordination between different Activities.
  • Fragment - The Fragment is a scaled down version of the Activity that allows for more than one screen to be placed in one screen. No that was not a typo, multiple screens in one screen! Let me explain, with the Activity, each focused thing you want to do such as " List Emails", "Read Emails", "Write New Email" occupies one screen. With Fragment, you can display the list of emails on the left and read the emails on the left of the same screen. Fragments were introduced to take advantage of the larger screen sizes of tablets while Activity was introduced back when phones were the only game in town,
  • Intent - Back to the analogy of the web page we used above, if you wanted to go from one web page (Activity) to another web page (Activity), instead of writing the programmatic logic that performs the communication from one Activity to the next, you simply declare your INTENT ion to communicate with another Activity. Intent is a brilliant concept that is unique to Android and one that you have to thoroughly understand to thrive in your Android career. It saves you time and provides seamless user experience for the user. Let's say you write an app that needs a picture say a Family Album App that displays family photos, instead of writing the immense lines of code that handles taking picture with the device camera, you simply declare an Intent with very few lines of code that you want to take a picture and Android will allow the user to take picture with any camera app on the phone and return that picture to your app.
  • Layout - If you are reading this article on a PC screen, look at the top right hand you will see a small section with a search box and a button. When you type in a search term in that box, it will search the site and display the result. That search box and the button and their look and feel is defined with a markup language called HTML/CSS, in Android this is analogous to XML layout. When you type a term in the search the logic to perform the search is written with a programming language called PHP, in Android this would be Java. If you have an Android device, take a look at any app, before you touch that app, everything you see in the screen is called the user interface and it is laid out ( layout ) with a markup language called XML. When you touch that app on your device, if it does any interaction, the logic that performs that interaction is written in Java. Starting Android development, you need to maintain competence in both XML and Java.
  • Shared Preference - This is an importance component of Android that with an interesting name, it allows you to save key value pairs of information to your device. Key value pairs is when you save information, you provide a key or an id so you can use it to retrieve that information later. For example, if you create a note taking app, the days can be the keys, so on Monday the key will be "monday" and the value will be " a very warm day", later if you need to retrieve the information you saved for Monday you can use the key "monday" to look it up in the Shared Preference. Other ways to save information in Android are using SQLite Database, saving on the Network, internal and external storage. Of these SQLite is the most prevalent; however at this point we will skip it for now, because if we delve into SQLite Database you may be overwhelmed, confused and amazed. At the end of this series, I will have a different tutorial series focused on Android SQLite.
  • ListView - textview and listview are the two most widely used widgets in Android development. Widgets are user interface (View) elements you see and interact with on Android screen such as button, textview, imageview, etc. Textview is used to display text and listview is used to display list and most Android apps will either have a text or list to display - list of contacts in phone, list of days of the week, list of options, list of customers, etc., there are lists everywhere and until recently these are displayed with a listview. The humble listview has however been replaced with a newer/advanced list rendered called RecyclerView.
  • Adapter - We just mentioned above that there are few options where you can save data in Android. Let's say you are building an app to display all the employee names of a 10,000 employee company. Of course you will use the listview to display the names, however the listview only knows how to display lists, it does not know how to figure out where the data you want to display in the list is coming from. That is where the adapter come in, it gets data from your datasource massages it and pass on to the listview. You will use listview or (now Recycler View) and adapter a lot in your Android development career.
  • Java - We use Java to inject interaction into our app. Java is one the most popular object oriented programming (OOP) language. OOP is a programming approach that models the application to be build using objects, methods and properties. If you are completely new to programming, you can certainly use an introductory class to Java such as this one. If you have some background in any programming especially an OOP language then I think you can proceed with learning Android development and pick up Java as needed. You can certainly proceed to learning Android development with zero programming background however you will struggle a lot as new concepts upon new concepts are thrown at you. It is certainly doable if you are formidable enough.

Android Development Tools

Image 1

Like every profession, there are tools that are used to develop Android app, and you will be an efficient developer to the extent that you master the tools of the trade. Here are the list of the tools that you need to get started with Android development.

  1. Android Device – You will need an Android device to constantly test the app that you are building. There are many Android devices and the phone and tablet are the most common form factor. Android phones and tablets comes in different makes and models such that it is impossible to have every make and model, however you need to have at-least one physical device. Alternatively, you can use a virtual device which are known as emulators to test your Android apps as you learn and build. I recommend Genymotion.com over the stock Android emulator because it is faster.
  2. Development Computer – You need a computer that you can use to write the code for your Android app. If you have a relatively modern computer, chances are that it will be sufficient to get started.
  3. Software Development Kit – I suspect that McDonald new franchisees will receive a set of guidelines and support materials from McDonald that will help them run their franchise such that its operations are consistent with every other McDonald, we can call this set of guideline business development kit. The same concept applies to software, when you develop software that is backed by a major Software corporation, they will normally provide you with a set of guidelines, tools, support materials, software packages, etc. that will aide you in creating software that is consistent with that platform. That package is called Software Development Kit of SDK, so for Android there is an Android SDK provided and supported by Google, if you develop for the iOS platform there is an SDK provided and supported by Apple, if you develop for the Windows platform there is an SDK provided and supported by Microsoft and so on.
  4. Integrated Development Environment – Painters use paint brush to create their work, potters use their hand to create pottery and programmers use the keyboard to type their code. This code can be typed into any editor such as notepad. However there are special purpose editors that are specifically made for writing code the same way special editors such as Microsoft Word are made for creating rich content. These special purpose editors are called Integrated Development Environment, because a lot of tools, bells and whistles are packed on top of the editor to make the work of the programmer easier. What's more, there are specialized IDEs suited for different type of software development such as web development and the one that is purpose built for Android development is called Android Studio.
  5. Android Studio – A laptop and Android Studio is all you need to start Android Development right now; because Android Studio is an all in one productivity software that includes an IDE, SDK and Emulator. You can certainly install all of these components separately however you are better off downloading the ready to go package from here.
  6. Notepad – Not a requirement but a neccessity, plan to take note from day one. You will encounter new concepts and terms and how-to as you get started with Android development. Do not commit everything to memory, write some down and go over your note as often as possible. Evernote is great option.

Setup - once you gather all the required tools, it is quite easy to setup and get started with Android development. Follow these steps to setup your Android development environment.

Setup Development Environment

Image 2

Time to put together our development environment.

  • Get a Computer - So what did you decide to do? Did you want to use your existing computer or get a new one. If you have the resources getting a new PC that is solely dedicated as a development machine is not a bad idea. If you want to wait to make sure that this is the career for you that is fine as well, either way if you want to proceed, you need to lay your hands on your own computer running either Windows, MAC or Linus operating system.
  • Check for Requirements - Once you have procured a development PC, the next step is to check if that PC meets the minimum requirement for running Android Studio. Most modern PCs either MAC or Windows will meet this requirement however for the interest of due diligence, you can find the system requirements here, if your PC exceeds the requirements the better.
  • Download Android Studio - This is the main event and you can find the download page here and there are download options for MAC, Windows and Linux, select the appropriate installation bundle for your operating system and download.
  • Download Java - Oops, I forgot to mention that there is a separate SDK for Java so we have to download that separately too. Even thought the system requirements listed Java 7, you can also use Java JDK 8 because Oracle no longer provides an update for JDK 7. You can download Java Development Kit 8 here select the appropriate installation file for your operating system .
  • Download Genymotion - The emulator from Genymotion provides better performance over the stock Android emulator. Registration is requirement before you can download the tool from here.
  • Install Java - Locate the executable that you downloaded from Java and run it, take note of the installation path because you will need it again.
  • Install Android Studio - Locate the Android Studio file that you downloaded and run it, follow the installation wizard prompt and when prompted, copy and paste the Java installation path.
  • Install Genymotion - In the same manner, located the Genymotion installer and run, follow the prompt of the installation wizard. It will install something called VirtualBox which it needs to create the emulators.
  • Create Workspace - Not strictly required, but now is a good time to create a dedicated folder in your hard drive where you will be saving your projects.
  • Run Android Studio - Take your new setup for a drive, fire up Android Studio and you will be presented with this prompt if everything worked as planned.

The post Beginning Android Development – Part 2/3 appeared first on Val Okafor.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) ValOkafor.com
United States United States
My name is Val Okafor, I am a Senior Software Engineer with specialization in Android Development. Learning and problem solving is my passion and I share my Android development knowledge through my blog ValOkafor.com.

My Android courses are the courses I wish I had when I started. I teach Android development in the context of a fully developed Android app. I believe that new Android concepts are better understood if they are presented in the context of creating an app from scratch to finish.

I focus on creating Productivity Android apps and besides Android development I have 7 years’ experience as System Administrator supporting Enterprise applications and 2 years’ experience as a Web Developer building websites using PHP and ASP.Net.

I have worked for corporations such as The Home Depot, American Council on Exercise, Legend3D and HD Supply, Inc. I have a bachelor's degree in Information Technology from National University San Diego, California and a master's degree in Software Engineering from Regis University Denver, Colorado.

I enjoy sharing my extensive work experience through my blog, social media.

Comments and Discussions

 
-- There are no messages in this forum --