The Fundamentals of Android Development.
Tags: beginners, android, mobile, kotlin
Published: 2022-11-10 20:39:41

**<u>Learning objectives</u>**
1. Provide an overview of the difference between mobile apps and mobile websites.
2. Explain how the mobile Operating system works.
3. The Android Operating system.
4. Introduction to Android development.

**<u>Mobile Platforms</u>**
 A mobile app is an installable software that runs on a smartphone device. Mobile apps use the device's hardware, and software features and usually provide an efficient, more intuitive, and seamless user experience. 

_What is the difference between a mobile app and a mobile website?_

A mobile app is software that runs on a hardware device whereas a mobile website works on a mobile app and does not involve any hardware to be functional.

_What are the advantages of mobile apps and a mobile website?_

<u>Mobile app</u>
1. Faster than mobile websites
2. Can access resources eg location, Bluetooth, etc.
3. Can work without internet access

<u>Mobile website</u>

1. Cheap to build and maintain
2. Need not to be built from scratch to be compatible with other platforms
3. No approval is required from Appstore

**Note:**_To determine whether to develop a mobile website or mobile app always ask yourself what specific actions you expect your product to perform._

## How does a Mobile OS work

The most fundamental software for any mobile device is its OS. An OS is designed to coordinate communications that occur between the hardware and apps of mobile devices. It manages the overall experiences of an app.

**Mobile operating system**
![mobileOS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfmeezt0m9ogn1h7seln.jpeg)
A mobile OS typically starts up when a device powers on, displaying different application icons and user interface (UI) elements to users.

<u>_Uses of Operating system_</u>
1. Allows smartphones, tablets, and personal digital assistants (PDAs) to run applications.
2. OS provides a channel with which applications can access device resources such as the processor, memory, Wi-Fi, Bluetooth, and more. 

The most common operating systems are _Android_ and _iOS_.

**<u>Android</u>**


![Android](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eqs8b6l5vhl81e94jnq7.jpeg)
- Android is a mobile OS that was released in 2008.
- Android OS is based on a modified version of the Linux kernel and is an open-source software which means anyone can modify it.
- Android OS was built primarily for smartphones, Chromebook, Android TV, and Android Auto, as well as wearables such as smartwatches.
- Android has built-in sensors such as gyroscopes and accelerometers, which gives users a multi-touch experience.

**<u>iOS</u>**


![ios](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8sx0ul0827lp1j8gbks.jpeg)
- iOS is Apple’s proprietary OS that runs on the iPhone, iPad, and other mobile devices
- Same as Android, iOS has built-in sensors such as gyroscopes and accelerometers, which gives users a multi-touch experience through several actions such as swiping, pulling, and tapping, and users can seamlessly interact with the screen.
- With the rise in popularity of iOS, developers now have more controls and access to its features.

Other mobile operating systems include _**kaiOS**_ which runs on Mozilla Firefox, _**SailfishOS**_ from Jolla, and _**Huawei's HarmonyOS**_ which was released in 2019 and runs on a microkernel that Huawei developed. Mostly used in IoT devices. 

## Android Platforms

- Being the most used operating system in the world, Android is not limited to only mobile devices. Android is also used to power other devices due to its openness to others.
- Android platforms include, Chromebook, Android TV, Android Auto, and WearOS.

 **Chromebook**


![chromebook](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qucxdn5zzessjrl22zoq.jpeg)
- Chromebooks are portable laptops that have support for running Android apps, which gives them more features.
- Chromebooks operate on Google's ChromeOS. 
- Ability to use convertible form factors to not necessarily build apps from scratch for phones and tablets from ChromeOS.

 **Android TV**


![androidtv](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3yhpdn72o0p80s52xzqw.jpeg)
- Android TV is designed to bring the mobile experience to your TV.
- The voice control feature of the TV allows you to have complete control over your devices.

**Android Auto**


![Android Auto](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/avwfyily7e1hldesrcn8.jpeg)
- It allows you to connect your phone to your car display.
- It automatically shows your apps on your car display and makes it possible for you to get driving directions and navigate seamlessly.
- Android Auto is made to help you stay focused on the road.

**WearOS**


![wearos](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emsg673iqoo0831nrks1.jpeg)
- WearOS is Google's Android OS that is specifically designed to power smartwatches and other wearables.
- The early release of WearOS allowed watching owners to install WearOS apps through their mobile phones from the google play store.

## Introduction to Android Development 

**Android Languages**

- In the world of Android development, **Java** and **Kotlin** are both extremely popular programming languages. 
- Java, which was released by Sun Microsystems in 1995 while Kotlin was introduced by JetBrains in 2011.

![kotlinvsjava](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9qu1qea9q117qxgfxij.jpeg)
-Kotlin has officially become the preferred language for Android app development due to the following reasons;
    1. It is concise and standardized hence low code errors.
    2. Easier to maintain complex projects due to low code.
    3. It is compatible with java hence easy to convert java 
       code to Kotlin.
    4. Kotlin handles errors that crash Android apps better 
       than java.

**The Android OS**

- Android is a Linux-based OS primarily designed for touchscreen mobile devices such as smartphones and tablets.
- Some of the unique features and characteristics of the Android OS include:

1. _**Near-field communication**_: This feature makes it easy for electronic devices to communicate over short distances.
2. _**Wi-Fi**_: With this feature, users can connect to various wireless access points around them due to these in-built technologies that support Wi-Fi protocols.
3. _**Custom home screen**_: Android OS allows you to further personalize your home screen the way you like it.
4. _**Widgets**_: Used for home-screen customization to give you a glance view of users' most important data.
5. _**App downloads**_: users can unlock the full potential of the Android operating system through app downloads.
6. _**Custom ROMS**_: Android can use customized and modified versions of Android OS to access features of a recent on an older device.

**The Android OS Architecture**

- Consists of components that Android needs to be functional.
- Android is built on top of an open-source Linux kernel and other C and C++ libraries exposed via application framework services.
- The Android OS is a stack of software components roughly divided into five sections:
   1. Applications                
   2. Application frameworks
   3. Android runtime
   4. Platform Libraries
   5. Linux Kernel

- These are separated into 4 layers, as shown in the architecture diagram below.

![AndroidOS layers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l1rfgxamwk4grs53oge7.PNG)

## Android App Cheatsheet

- To get started with developing an app, you need a clear understanding of relevant concepts.
- These concepts include:

**Top-level component**

- Enables apps to connect to the internet, make calls, and take pictures through BroadcastReceiver, ContentProvider, and Service and activity accessible in Android SDK.

**Activity Components**

- These are activities present for content users to interact with on the screen.
- Single activity architecture pattern allows one activity or a relatively small number of activities to be used for an entire app.

**Android views**

- This is the design interface that occupies a rectangular area on the screen and is responsible for drawing and event handling. It displays text, images, and more.

**Android layout files**

- In Android, each layout is represented by an XML file. These plain text files serve as blueprints for the interface that your application presents to the user.

**Project files**

- Android Project Files belong to one of three main categories: **configuration**,**code**, and **resource**. _Configuration files_ define the project structure, _code files_ provide the logic, and _resource files_ provide essentially everything else.

## Anatomy of An Android App

- This basically looks into the components that go in when creating an App.

![Anatomy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vynor3c0eznuhrah9cd.jpeg)
- An Android app is made up of four major components that serve as the building blocks of any Android app in the market.
- The four major components include:

1. **Activities**: This is the entry point of users that represent a single user. It allows you to place UI components, widgets, or user interfaces on a single screen. eg _a music player app may have an activity that shows you a list of your favorite songs, another activity that allows you to play a specific song, and another which shows you a list of trending songs._
2. **Services**: They run in the background and constantly update the data sources and activities with the latest changes. It also performs tasks when users are not active on applications. eg _A good example of a service is chatting with someone whilst listening to music._
3. **Broadcast Receiver**: Its purpose is to respond to messages from other applications or systems in real time. eg,_imagine you're enjoying your favorite song on your music app when you get a notification that you're running low on battery power._ 
4. **Content providers**: It's responsible for sharing data between applications. eg _A typical example is a social media app that allows users to share their images online._

 These Android components are coupled by a configuration file called **AndroidManifest.xml**. It is used to specify each component and how they interact with each other.

![Androidmanifest](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pirqbpipdpub1pu3gtc9.jpeg) 

## Extensible Markup Language(XML)

- XML (Extensible Markup Language) is used in the presentation of different kinds of data. Its main function is to create data formats that are used to encode information for documentation, records, transactions, and several other data formats.
![xml](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbhohy4eduweqbq31to2.jpeg)
- For an XML document to be valid, the following conditions must be fulfilled:

1. The document must be well-formed.
2. The document must comply with all the rules of the XML syntax.

**THE END.**

**Thank you for taking the time to go through the article!!**



![TheEnd](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v75bei3o07x5f3r3hx4h.jpeg)