Thursday, December 26, 2024
Google search engine
HomeGuest BlogsAndroid App Development Fundamentals for Beginners

Android App Development Fundamentals for Beginners

Android is an operating system that is built basically for Mobile phones. It is based on the Linux Kernel and other open-source software and is developed by Google. It is used for touchscreen mobile devices such as smartphones and tablets. But nowadays these are used in Android Auto cars, TV, watches, camera, etc. It has been one of the best-selling OS for smartphones. Android OS was developed by Android Inc. which Google bought in 2005. Various applications (apps) like games, music player, camera, etc. are built for these smartphones for running on Android. Google Play store features more than 3.3 million apps. The app is developed on an application known as Android Studio. These executable apps are installed through a bundle or package called APK(Android Package Kit)

Android Fundamentals

1. Android Programming Languages

In Android, basically, programming is done in two languages JAVA or C++ and XML(Extension Markup Language). Nowadays KOTLIN is also preferred. The XML file deals with the design, presentation, layouts, blueprint, etc (as a front-end) while the JAVA or KOTLIN deals with the working of buttons, variables, storing, etc (as a back-end).

2. Android Components

The App components are the building blocks of Android. Each component has its own role and life cycles i.e from launching of an app till the end. Some of these components depend upon others also. Each component has a definite purpose. The four major app components are: 

  • Activities
  • Services
  • Broadcast Receivers:
  • Content Provider:

Activities: It deals with the UI and the user interactions to the screen. In other words, it is a User Interface that contains activities. These can be one or more depending upon the App. It starts when the application is launched. At least one activity is always present which is known as MainActivity. The activity is implemented through the following.  

Syntax:

public class MainActivity extends Activity{
  // processes
}

To know more Activities please refer to this article: Introduction to Activities in Android

Services: Services are the background actions performed by the app, these might be long-running operations like a user playing music while surfing the Internet. A service might need other sub-services so as to perform specific tasks. The main purpose of the Services is to provide non-stop working of the app without breaking any interaction with the user. 

Syntax:

public class MyServices extends Services{
  // code for the services
}

To know more Services please refer to this article: Services in Android with Example

Broadcast Receivers: A Broadcast is used to respond to messages from other applications or from the System. For example, when the battery of the phone is low, then the Android OS fires a Broadcasting message to launch the Battery Saver function or app, after receiving the message the appropriate action is taken by the app. Broadcast Receiver is the subclass of BroadcastReceiver class and each object is represented by Intent objects. 

Syntax:  

public class MyReceiver extends BroadcastReceiver{
   public void onReceive(context,intent){
 }

To know more Broadcast Receivers please refer to this article: Broadcast Receiver in Android With Example

Content Provider: Content Provider is used to transferring the data from one application to the others at the request of the other application. These are handled by the class ContentResolver class. This class implements a set of APIs(Application Programming Interface) that enables the other applications to perform the transactions. Any Content Provider must implement the Parent Class of ContentProvider class. 

Syntax:  

public class MyContentProvider extends ContentProvider{
   public void onCreate()
   {}
}

To know more Content Provider please refer to this article: Content Providers in Android with Example

3. Structural Layout Of Android Studio

The basic structural layout of Android Studio is given below:

Structural Layout Of Android Application

The above figure represents the various structure of an app. 

Manifest Folder: Android Manifest is an XML file that is the root of the project source set. It describes the essential information about the app and the Android build tools, the Android Operating System, and Google Play. It contains the permission that an app might need in order to perform a specific task. It also contains the Hardware and the Software features of the app, which determines the compatibility of an app on the Play Store. It also includes special activities like services, broadcast receiver, content providers, package name, etc.

Java Folder: The JAVA folder consists of the java files that are required to perform the background task of the app. It consists of the functionality of the buttons, calculation, storing, variables, toast(small popup message), programming function, etc. The number of these files depends upon the type of activities created.

Resource Folder: The res or Resource folder consists of the various resources that are used in the app. This consists of sub-folders like drawable, layout, mipmap, raw, and values. The drawable consists of the images. The layout consists of the XML files that define the user interface layout. These are stored in res.layout and are accessed as R.layout class. The raw consists of the Resources files like audio files or music files, etc. These are accessed through R.raw.filename. values are used to store the hardcoded strings(considered safe to store string values) values, integers, and colors. It consists of various other directories like:

  • R.array :arrays.xml for resource arrays
  • R.integer : integers.xml for resource integers
  • R.bool : bools.xml for resource boolean
  • R.color :colors.xml for color values
  • R.string : strings.xml for string values
  • R.dimen : dimens.xml for dimension values
  • R.style : styles.xml for styles

Gradle Files: Gradle is an advanced toolkit, which is used to manage the build process, that allows defining the flexible custom build configurations. Each build configuration can define its own set of code and resources while reusing the parts common to all versions of your app. The Android plugin for Gradle works with the build toolkit to provide processes and configurable settings that are specific to building and testing Android applications. Gradle and the Android plugin run independently of Android Studio. This means that you can build your Android apps from within Android Studio. The flexibility of the Android build system enables you to perform custom build configurations without modifying your app’s core source files. 

Basic Layout Can be defined in a tree structure as: 

Project/
   app/
      manifest/
         AndroidManifest.xml
   java/
      MyActivity.java   
      res/
         drawable/  
            icon.png
            background.png
         drawable-hdpi/  
            icon.png
            background.png  
         layout/  
            activity_main.xml
            info.xml
         values/  
            strings.xml 

4. Lifecycle of Activity in Android App 

The Lifecycle of Activity in Android App can be shown through this diagram: 

Activity Lifecycle in Android with Demo App

States of Android Lifecycle:

  1. OnCreate: This is called when activity is first created.
  2. OnStart: This is called when the activity becomes visible to the user.
  3. OnResume: This is called when the activity starts to interact with the user.
  4. OnPause: This is called when activity is not visible to the user.
  5. OnStop: This is called when activity is no longer visible.
  6. OnRestart: This is called when activity is stopped, and restarted again.
  7. OnDestroy: This is called when activity is to be closed or destroyed.

To know more about Activity Lifecycle in Android Please refer to this article: Activity Lifecycle in Android with Demo App

To begin your journey in Android you may refer to these tutorials:

Last Updated :
08 Jul, 2022
Like Article
Save Article


Previous

<!–

8 Min Read | Java

–>


Next


<!–

8 Min Read | Java

–>

Share your thoughts in the comments

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments