The presentation that covers the basics of Android Development.
It was created to be used in an Android Workshop for Beginners , in an Event called GDG School organized by The Community of GDG Algiers in December the 14th and 15th 2018.
The Presentation was created and the talk was delivered by me Abderraouf GATTAL (https://www.linkedin.com/in/abderraouf-gattal/).
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
GDG School Android Workshop
1. READ ME
01 Android Studio should be installed.
02 SDK, Gradle, JDK should be installed.
03 OOP basic knowledge.
04 Motivation, and Hunger for Learning.
05 Enjoy it! :)
1
6. 6
WHAT IS AN
ANDROID
APP?
It’s a small piece of software that runs on Smartphone’s OS Android, it can be written
using Kotlin, Java, or C++ programming languages. Android SDK (Software
Development Kit) tools compile your code along with any data and resource files into
an APK (Android Package), which is an archive file with an .apk suffix.
7. Each component is an entry point through which the system or a user can enter Android
apps. Some components depend on others.
APP COMPONENTS
THE ESSENTIALBUILDING BLOCKS OF AN ANDROID APP.
7
8. 8
APP COMPONENTS
Broadcast Receivers
A broadcast receiver is a component that
enables the system to deliver events to the
app outside of a regular user flow, allowing
the app to respond to system-wide broadcast
announcements.
Although broadcast receivers don't display a
user interface, they may create a status bar
notification to alert the user when a broadcast
event occurs.
ContentProviders
A content provider manages a shared set of
app data that you can store in the file system,
in a SQLite database, on the web, or on any
other persistent storage location that your
app can access. Through the content
provider, other apps can query or modify the
data if the content provider allows it.
Services
A service is a component that runs in the
background to perform long-running
operations or to perform work for remote
processes.
A service does not provide a user interface.
9. An activity is the entry point for interacting with the user. It represents a single screen with a
user interface.
APP COMPONENTS
Activities
9
10. 10
ACTIVITY
LIFECYCLE
To navigate transitions between stages of the activity lifecycle, the Activity class
provides a core set of six call-backs: onCreate(), onStart(), onResume(),
onPause(), onStop(), and onDestroy(). The system invokes each of these call-
backs as an activity enters a new state.
12. ANDROID
& XML
12
XML stands for Extensible Markup Language. Much like
HTML (or Hyper Text Markup Language), XML is also a
markup language. It was created as a standard way to
encode data in internet-based applications.
However, unlike HTML, XML is case-sensitive, requires
each tag is closed properly, and preserves whitespace.
In Android there are several purposes of using XML, each
purpose needs a specific type of xml files.
XML & IT’S USE
13. 13
VIEW GROUPS
& VIEWS
Views
A View is the basic building block for user interface components.
It (to be precise android.view.View) is the base class for widgets,
which are used to create interactive UI components (buttons, text
fields, etc.). It is the superclass for all GUI components in Android.
ViewGroups
A ViewGroup is an invisible object (a special view) used to contain
other View and ViewGroup objects (called children.) in order to
organize and control the layout of a screen.
15. 15
ANDROID
INTENTS
INTENTS
An Intent is a messaging object you can use to request an action from
another app component. Although intents facilitate communication between
components in several ways.
EXPLICIT INTENTS
specify which application will satisfy the intent, by supplying either the target
app's package name or a fully-qualified component class name.
IMPLICIT INTENTS
do not name a specific component, but instead declare a general action to
perform, which allows a component from another app to handle it.
19. 19
MAIN
CHALLENGES
UI DESIGN
Make it responsive to as much phones as possible.
Make it pretty.
Make it the best.
LANDSCAPE
Make a special UI for the landscape mode.
DATABASE
Add a data base to store and retrieve data from .
Android is an operating system that started as an impossible idea in the early 2000’s by Andrew Roben. Yet now and after the faillures and success Android became the Os that covers more than 85% of the phones in the world, in addition to the smart TVs, Smart watches and IOT devices, …
It was not until the launch of Android 1.5, just a few months later in April 2009, that the OS version got its first public code name: “Cupcake
“Since these devices make our lives so sweet, each Android version is named after a dessert.”
It’s a small piece of software that runs on Smartphone’s OS Android.”, well that’s true but as a developer you should know more about the technical aspect like it can be written using Kotlin, Java, and C++ programming languages. Android SDK (Software Development Kit) tools compile your code along with any data and resource files into an APK (Android Package), which is an archive file with an .apk suffix. One APK file contains all the contents of an Android app and is the file that Android-powered devices use to install the app.
App components according to the official Android Documentation are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components
Services : For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with an activity.
Broadcast receivers : Because broadcast receivers are another well-defined entry into the app, the system can deliver broadcasts even to apps that aren't currently running. So, for example, an app can schedule an alarm to post a notification to tell the user about an upcoming event... and by delivering that alarm to a BroadcastReceiver of the app, there is no need for the app to remain running until the alarm goes off. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Apps can also initiate broadcasts—for example, to let other apps know that some data has been downloaded to the device and is available for them to use.
Content Providers: For example, the Android system provides a content provider that manages the user's contact information. As such, any app with the proper permissions can query the content provider, such as ContactsContract.Data, to read and write information about a particular person. It is tempting to think of a content provider as an abstraction on a database, because there is a lot of API and support built in to them for that common case. However, they have a different core purpose from a system-design perspective.
onCreate()
You must implement this callback, which fires when the system first creates the activity. On activity creation, the activity enters the Created state. In the onCreate() method, you perform basic application startup logic that should happen only once for the entire life of the activity. For example, your implementation of onCreate() might bind data to lists, and instantiate some class-scope variables.
onStart()
When the activity enters the Started state, the system invokes this callback. The onStart() call makes the activity visible to the user, as the app prepares for the activity to enter the foreground and become interactive. For example, this method is where the app initializes the code that maintains the UI. The onStart() method completes very quickly and, as with the Created state, the activity does not stay resident in the Started state. Once this callback finishes, the activity enters the Resumed state, and the system invokes the onResume() method.
onResume()
When the activity enters the Resumed state, it comes to the foreground, and then the system invokes the onResume() callback. This is the state in which the app interacts with the user. The app stays in this state until something happens to take focus away from the app. Such an event might be, for instance, receiving a phone call, the user’s navigating to another activity, or the device screen’s turning off. When the interruptive event occurs, the activity enters the Paused state, and the system invokes the onPause() callback. If the activity returns to the Resumed state from the Paused state, the system once again calls onResume() method. For this reason, you should implement onResume() to initialize components that you release during onPause(), and perform any other initializations that must occur each time the activity enters the Resumed state.
onPause()
The system calls this method as the first indication that the user is leaving your activity (though it does not always mean the activity is being destroyed); it indicates that the activity is no longer in the foreground (though it may still be visible if the user is in multi-window mode). Use the onPause() method to pause or adjust operations that should not continue (or should continue in moderation) while the Activity is in the Paused state, and that you expect to resume shortly. There are several reasons why an activity may enter this state. For example:
Some event interrupts app execution, as described in the onResume() section. This is the most common case.
In Android 7.0 (API level 24) or higher, multiple apps run in multi-window mode. Because only one of the apps (windows) has focus at any time, the system pauses all of the other apps.
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.
However, as mentioned above in the onResume() section, a Paused activity may still be fully visible if in multi-window mode. As such, you should consider using onStop() instead of onPause() to fully release or adjust UI-related resources and operations to better support multi-window mode.
onStop()
When your activity is no longer visible to the user, it has entered the Stoppedstate, and the system invokes the onStop() callback. 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. In the onStop() method, the app should release or adjust resources that are not needed while the app is not visible to the user. For example, your app might pause animations or switch from fine-grained to coarse-grained location updates. Using onStop() instead of onPause() ensures that UI-related work continues, even when the user is viewing your activity in multi-window mode. You should also use onStop() to perform relatively CPU-intensive shutdown operations. For example, if you can't find a more opportune time to save information to a database, you might do so during onStop().
onDestroy()
onDestroy() is called before the activity is destroyed. The system invokes this callback either because:
the activity is finishing (due to the user completely dismissing the activity or due to finish() being called on the activity)
the system is temporarily destroying the activity due to a configuration change (such as device rotation or multi-window mode)
XML stands for Extensible Markup Language. Much like HTML (or Hyper Text Markup Language), XML is also a markup (A markup language is a computer language that uses tags to define elements within a document. It is human-readable, meaning markup files contain standard words, rather than typical programming syntax) language. It was created as a standard way to encode data in internet-based applications. However, unlike HTML, XML is case-sensitive, requires each tag is closed properly, and preserves whitespace.
In Android there are several purposes of using XML, each purpose is needs a specific type of xml files.
Layout XML Files : Define the actual UI of an Application.
Manifest xml File (Mainfest.xml) : Define all the components of the Application.
Strings xml File(strings.xml) : Replace the Hard-coded strings with a single string.
Styles xml File(styles.xml) : Define the different styles and looks for the UI of the application
Drawable xml Files : Provide various graphics to the elements or views of the application.
Color xml File (colors.xml) : Define the App’s colors.
Dimension xml File(dimens.xml) : Define the dimensions of the Views.
Views:
A View is the basic building block for user interface components.
It (to be precise android.view.View) is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). It is the superclass for all GUI components in Android.
ViewGroups
A ViewGroup is an invisible object (a special view) used to contain other View and ViewGroup objects (called children.) in order to organize and control the layout of a screen.
Constraint Layout: (Constraint means a restriction or a limitation.) ConstraintLayout is a view group that allows adding elements from the palette on the screen and add restrictions to each of its sides. With these constraints, we can specify the distance of each element from the border or from each other.
Linear Layout: LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.
Relative Layout: RelativeLayout is a view group that displays child views in relative positions.
Table Layout: TableLayout is a view that groups views into rows and columns.
Grid View: GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid.
List View: ListView is a view group that displays a list of scrollable items.
INTENTS
An Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways.
IMPLICIT INTENTS
do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.
EXPLICIT INTENTS
specify which application will satisfy the intent, by supplying either the target app's package name or a fully-qualified component class name.
Challenges hint:
int orientation = getResources().getConfiguration().orientation
if (orientation == Configuration.ORIENTATION_LANDSCAPE) { // In landscape }
else { // In portrait }