+ Reply Thread

 Hello Guys, starting fromtoday I will be taking you tutorials on Android Development from novice to pro. Android apps are beauty, and they require the right hand to make them glow; In other for us to truly appreciate the beauty of Android Development, is very essential for us to have a very good understanding of Java programming language, “Android itself was built using Java”; In regards to this we will be explaining most of the Java Api’s ”Application programming interface” use in Android as we proceed, so if you are a beginner to Java programming language this tutorial is also for you, grab a cup of coffee and sit tight.

                                             DEFINITION OF TERMS USED
  • ·        Actions or Method: These are series of instructions laid out by a programmer, to be performed depending on users input or interactions.
  • ·        Instances or Objects: An instance of app or class in android or java in general is an object created for it; an object in it simplest form are bunch of reusable codes                   which are pierced or fused together to perform series of operations; for example, an object can be created for picking a photo from gallery to crop the photo.
  •         A Class: A class in android or java in general, is a template or blueprint, that can be use in creating an application. A class contain codes or bunch of instructions that             can be tailored to suit the application or program in which it is creating.
  •         CallBacks: Callbacks these are methods or operations that have already been created to perform a particular task, since they are already created they can be called              anytime in the app and that’s what brought about the name “callbacks”.
  •         Implementation: This is the process of using a callback, after agreeing to the various terms and condition associated with it usage, its more of like a contract; agreeing         to do certain things in certain ways, if violated an error will be pop-up via the coding screen.
  •       Views: This are controls or GUI’s(graphic user interface) that can be clicked, mouse over or used in an android application to perform a particular operation or action.
                                          Android Application Components:

Application components are the essential building blocks of an Android application. These components are loosely coupled by the application manifest  file ”AndroidManifest.xml” that describes each component of the application and how they interact. There are four main components that can be used within an Android application, they are:
·        Activities:
They dictate the UI and handle the user interaction to the smart phone screen. Activities are similar to pages on a book, each page contain contents and its design in such a way to facilitate reading, each Activity of an application has its own specific design or structure to fit the operation it perform, its safe to say a user layout is part of an activity.
·        Services:
 They handle background processing associated with an application.Service run in the main  or UI thread of its hosting process; the service does not create its own thread and does not run in a separate process unless you specify otherwise. For example a service can handle the operation of playing your music, Iterating or searching through your music list and serving the user interface with music from the list of music; this music is played by a service. A service can be likened to a house boy, and the house owner is the activity the service runs on.
     Broadcast Receivers:
They handle communication between Android OS and applications. As the name implies, they are responsible for broadcasting or consuming events or actions that happens on the Android OS by responding with the appropriate event handlers or callback methods. For example an incoming call is a broadcast or event and there are several broadcast receivers
or for short receivers created specifically to alert or make you aware of the operations or event handlers method that can be performed on it. For example you might decide to pick a call, reject or bounce the call, all this are handlers method or callbacks that can be performed on an Incoming call broadcast.
   Content Providers:
They handle data and database management issues. Our contacts residing in our phone are stored in the android native database, this database can be manipulate, control or serve to the user when its been demanded by the content provider component of an application. Content provider are data’s provider, they are the agent responsible for providing you data’s for example: List of Music, List of contacts, List of videos e.t.c.
                                                                                         Activities In Android
An Activity represent a single screen within an Android Application, it’s the user interface that users interact with to perform some sets of action within an android application. For example when we dial-up numbers for a phone call, we are making use of several activities:
          The screen for dialing the numbers is an activity, and the minute we start dialing a number we are interacting with an
          activity of the phone dialer application.
·         The screen for monitoring phone calls state is also another activity, all this activity fused together which might include the rest of the android component makes up an                     android application.
The Android application is alive, when we interact with it, it responds back with series of actions, when we click an app icon on our phones, we are launching an activity and this activity is called the Launcher Activity of an android application; An Activity has life cycles:
           An Activity life cycle is the different state an activity can exist in during the entire life of that activity.
The Activity Life Cycle:
As a user navigates through, out of, and back to your app, the Activity instances,in your app transition through different states in their life cycle. The Activity class provides a number of callbacks, that allow the activity to know that a state has changed:
        that the system is creating,stopping, or resuming an activity, or destroying the process in which the
        activity resides.
Within the life cycle callback methods, you can declare how your activity behaves when the user leaves and re-enters the activity.For example,good implementation of the life cycle callbacks can help ensure that your app avoids:
  • ·       Crashing if the user receives a phone call or switches to another app while using your app.
  •         Consuming valuable system resources when the user is not actively using it.
  •         Losing the user's progress if they leave your app and return to it at a later time.
  • Crashing or losing the user's progress when the screen rotates between landscape and portrait orientation.
The Activity class provides a core set of six callbacks:
     1.   Oncreate(): This callback is called when the activity is first created, you perform basic operation on this method, all application initialization or preliminary operations is performed via this callback. For example operations like, Initializing or loading the views so they can be used by the application are done here, its also where you perform basic application start up logic that can happen only once within that application life cycle.
     2.   OnStart(): This callback is called when the activity is first started, when it becomes visible to the user, this method is where the activity initializes the code that maintain the UI. The onstart method complete very quickly and, as with the oncreate state, the activity does not stay resident in the started state once this callback finishes the activity enters the resume state.
    3.   OnResume(): This is the state in which the app interacts with the Users, the app stays in this state until something happens to take the focus away from the app. For example opening another activity will take the activity off the onresume state, this can be seen when we are operating a particular app, and someone calls us, the app is taken off the onresume state in this case.
   4.   OnPause(): This callback is called When the user leaves you app, and intend coming back shortly. For example when you minimize your app to use another app, there are several reasons why the OnPause is called by your app:
  •   Some Events interrupt app execution.
  •   A new,semi-transparent activity (such as a dialog) opens. As long as the activity is still partially visible but not in focus, it remains paused.
  5.   OnStop(): This callback is called when the user activity is no longer visible to the user. This may occur, for example, when a newly launched activity covers the entire screen. The system may also call onstop when the activity has finished running, and is about to be terminated.
6.   OnDestoyed(): This callback is called before the activity is destroyed. This is the final call that the activity receives. The system either invokes this callback because the activity is finishing due to someone's calling finish() , or because the system is temporarily destroying the process containing the activity to save space.
The Diagram below explain the usage of the six callbacks provided by the activity class:
[img width=360,height=465]file:///C:/Users/ABOHIE~1/AppData/Local/Temp/msohtmlclip1/01/clip_image002.gif[/img] The diagram is a comprehensive description of an Activity life cycle work flow, sorry for any inconvenience you might have not able to see it, we will fix this later.
In this tutorial, you learned about Android Application component, our learning here was geared towards understanding how the Android component works, starting with
the Android Activity component. In the next series of tutorials we will be
diving straight to Android studio, where we will start developing  applications  to better explain how the android activity functions with its callbacks.
The Android Official website:developer.android.com
The TutorialsPoint Team:tutorialspoint.com.
keep up the good work friend!
Back to top