Mobile Application Development
Mobile Application Development
Development
Google wanted Android to be open and free; hence, most of the Android code was released under the open source
Apache License, which means that anyone who wants to use Android can do so by downloading the full Android source
code. Moreover, vendors (typically hardware manufacturers) can add their own proprietary extensions to Android and
customize Android to differentiate their products from others. This simple development model makes Android very
attractive and has thus piqued the interest of many vendors. This has been especially true for companies affected by the
phenomenon of Apple’s iPhone, a hugely successful product that revolutionized the smartphone industry. Such
companies include Motorola and Sony Ericsson, which for many years have been developing their own mobile operating
systems. When the iPhone was launched, many of these manufacturers had to scramble to find new ways of revitalizing
their products. These manufacturers see Android as a solution — they will continue to design their own hardware and use
Android as the operating system that powers it.
The main advantage of adopting Android is that it offers a unified approach to application development. Developers need
only develop for Android, and their applications should be able to run on numerous different devices, as long as the
devices are powered using Android. In the world of smartphones, applications are the most important part of the success
chain. Device manufacturers therefore see Android as their best hope to challenge the onslaught of the iPhone, which
already commands a large base of applications.
Android Version
Android Devices in the Market
➤ Smartphones
➤ Tablets
➤ E-reader devices
➤ Netbooks
➤ MP4 players
➤ Internet TVs
The Android Developer Community
Stack Overflow
Android Discuss
What is Flutter?
A framework that allows you to build native cross platform (iOS, Android) apps with one
programming language and codebase.
Flutter uses a programming language called Dart. Dart focused on frontend (mobile apps, web
app) user interfaces (UI development). Dart provides Utility functions and UI elements called
widgets. In flutter everything is a widget and it works like a widget tree.
Build = output of the flutter application. It is generated and managed by flutter SDK
Lib: main file of the application and its a super important file of the project
.package: it's also generated automatically by flutter and we don’t work with it. It managed all dependencies
Scaffold
Appbar
title
leading
actions
flexiableSpace
SafeArea
Container
Components of Screen Con’t
Text
RichText
Column
Row
Button
Components of Screen Con’t
Scaffold: the Scaffold widget implements the basic Material Design visual layout, allowing you to easily add
various widgets such as AppBar, BottomAppBar, FloatingActionButton, Drawer, SnackBar, BottomSheet, and
more.
AppBar The AppBar widget usually contains the standard title, toolbar, leading, and actions properties (along
with buttons), as well as many customization options.
title The title property is typically implemented with a Text widget. You can customize it with other widgets such
as a DropdownButton widget.
leading The leading property is displayed before the title property. Usually this is an IconButton or BackButton.
actions The actions property is displayed to the right of the title property. It’s a list of widgets aligned to the
upper right of an AppBar widget usually with an IconButton or PopupMenuButton.
Con’t
flexibleSpace The flexibleSpace property is stacked behind the Toolbar or TabBar widget. The height is usually
the same as the AppBar widget’s height. A background image is commonly applied to the flexibleSpace
property, but any widget, such as an Icon, could be used.
SafeArea The SafeArea widget is necessary for today’s devices such as the iPhone X or Android devices with a
notch (a partial cut-out obscuring the screen usually located on the top portion of the device). The SafeArea
widget automatically adds sufficient padding to the child widget to avoid intrusions by the operating system.
You can optionally pass a minimum amount of padding or a Boolean value to not enforce padding on the top,
bottom, left, or right.
Container The Container widget is a commonly used widget that allows customization of its child widget. You
can easily add properties such as color, width, height, padding, margin, border, constraint, alignment, transform
(such as rotating or sizing the widget), and many others.
RichText The RichText widget is a great way to display text using multiple styles. The RichText widget takes
TextSpans as children to style different parts of the strings.
Con’t
Column A Column widget displays its children vertically. It takes a children property containing an array of
List<Widget>, meaning you can add multiple widgets. The children align vertically without taking up the full
height of the screen.
Row A Row widget displays its children horizontally. It takes a children property containing an array of
List<Widget>. The same properties that the Column contains are applied to the Row widget with the exception
that the alignment is horizontal, not vertical.
Buttons There are a variety of buttons to choose from for different situations such as RaisedButton,
FloatingActionButton, FlatButton, IconButton, PopupMenuButton, and ButtonBar.
Working with Forms and Validations
https://pub.dev/packages/form_field_validator
Working with Layout Responsiveness
https://pub.dev/packages/sizer
Row Widget
A Row is a widget used to display child widgets in a horizontal manner. The Row widget
does not scroll. If you have a line of widgets and want them to be able to scroll if there is
If we wished to display three text widgets within a row we can create a Row widget like
below:
Row Widget
Row(
children: [
Container(
color: Colors.orange,
),
Container(
color: Colors.orange,
),
Container(
color: Colors.orange,
),], )
Column Widget
A Column is a widget used to display child widgets in a vertical manner. The Column
widget does not scroll. If you have a line of widgets and want them to be able to scroll if
If we wished to display three text widgets within a column we can create a Column widget
like below:
Column Widget
Column(
children: [
Container(
color: Colors.orange,
),
Container(
color: Colors.orange,
),
Container(
color: Colors.orange,
),], )
Column and Row have the same properties. So in
the examples below we are working in the same time
with both widgets.
What is the CrossAxis in
Row and Column
?
CrossAxisAlignment Propery
?
MainAxisAlignment Propery
MainAxisAlignment.start
Place the children as close to the start of the main axis as possible.
MainAxisAlignment.center
A flutter plugin for Easily make Flutter apps responsive. Automatically adapt UI to
different screen sizes. Responsiveness made simple.
Sizer Parameters
return MaterialApp();
)
Good Luck
Threading
Threading in Android
In Android, you can categorize all threading components into two basic categories:
1. Threads that are attached to an activity/fragment: These threads are tied to the lifecycle
2. Threads that are not attached to any activity/fragment: These threads can continue to
run beyond the lifetime of the activity/fragment (if any) from which they were spawned.
Con’t
1. AsyncTask
2. Loaders
Con’t
1. Service
2. Intent Service
Con’t
For the above two threading components,There are five types of thread are using
1. Main thread
2. UI thread
3. Worker thread
4. Any thread
5. Binder thread
Main Thread
When an application is launched in Android, it creates the first thread of execution, known as the
“main” thread. The main thread is responsible for dispatching events to the appropriate user
interface widgets as well as communicating with components from the Android UI toolkit.
To keep your application responsive, it is essential to avoid using the main thread to perform any
Network operations and database calls, as well as loading of certain components, are
common examples of operations that one should avoid in the main thread. When they are
called in the main thread, they are called synchronously, which means that the UI will
remain completely unresponsive until the operation completes. For this reason, they are
usually performed in separate threads, which thereby avoids blocking the UI while they
are being performed (i.e., they have performed asynchronously from the UI).
Main Thread
2. UI Thread
UI Thread allows your tasks to do background work and then move the results to UI elements such as
bitmaps.
Every app has its own special thread that runs UI objects such as View objects, This thread is called the
UI thread. Only objects running on the UI thread have access to other objects on that thread. Because
tasks that you run on a thread from a thread pool aren't running on your UI thread, they don't have
access to UI objects. To move data from a background thread to the UI thread, use a Handler that's
Denotes that the annotated method can be called from any thread
The main purpose of this method is to indicate that you believe a method
can be called from any thread; static tools can then check that nothing you
call from within this method or class has more strict threading
requirements.
Asynchronous Threads
In an asynchronous system, the program asks the OS for the file and
returns the control to the mathematical operation to be executed on the
CPU, while waiting for the file.
Let’s take a simple analogy; you have a friend, and you decided to make
dinner together.
Asynchronous vs Multithreading
Async is when you say to your friend, “You go to the store and buy pasta. Let me know
when you get back, to make dinner together. Meanwhile, I’ll prepare sauce and
drinks.”
Threading is, “You boil the water. I’ll heat the tomato sauce. While the water is boiling, ask
me and I’ll put the pasta in. When the sauce is hot, you can add cheese. When both are
done, I’ll sit down and you serve dinner. Then we eat.”. In the threading analogy, we can
see the sequence of “When, Do” events, which represent the sequential set of
instructions per each person (thread).
In a nutshell, for large scale applications with a lot of I/O operations and different
computations, using asynchronous multithreading programming flow, will utilize
the computation resources, and take care of non-blocking functions. This is the
programming model of any OS!
With more power, comes more responsibility! So if we decided to implement this model,
we have to take care of different issues like race condition, deadlocks, shared resources,
and callbacks events.