android_mod_1
android_mod_1
COLLEGE,KOTTAPPADY
(Affiliated to MG University, Approved by Govt.of Kerala)
BCA
ANDROID
OPERATING SYSTEMS
MIDDLEWARE
KEY APPLICATION
OPEN HANDSET ALLIANCE
• Google-develops Android
• OEMs(Original Equipment Manufacturers)-manufacture
hardware as well as custom application components
• Application Development Companies-employ Android
developers and also contract out the product development
to services companies.
• Freelance Android developers-Developers create their own
applications and publish them on Google playstore.
Why ANDROID??
• Browser
• Desktop
• Connectivity
• Multi-Notification
• Endless Personalization
• Market
• Google Integration
• Open Source
• Open to Carrier
• Future
WHAT IS AN
APK?
APK(ANDROID PACKAGE KIT or ANDROID
APPLICATION PACKAGE)-file format used by Android
for the distribution and installation of mobile apps,
mobile games etc.
• Required libraries.
• Debugger.
• An emulator.
• Relevant documentation for the Android application
program interfaces (APIs).
• Sample source code.
• Tutorials for the Android OS.
Android
Versions
Other versions
❖ Android 5.0 and 5.1 Lollipop
❖ Android version 6.0: Marshmallow
❖ Android versions 7.0 and 7.1: Nougat
❖ Android version 8.0 and 8.1: Oreo
❖ Android version 9: Pie
❖ Android version 10
❖ Android version 11
Android
Activity
• 2001-search service for wireless device
• 2005-Acquire Android
(Acquire Skia(2d graphics for mobile device)
Acquire RegWireless(Browser and email for mobile device)
Move engineers from PlamSource))
1.Applications
2.Application Framework
3.Libraries
4.Android Runtime
5.Linux Kernel
1.APPLICATIONS
❖ All applications in this layer are written using Java.
❖ The applications that an android device provide includes
• Email client
• SMS programs
• Maps
• Browser
• Calender
• Contacts
• Games etc
2.APPLICATION
FRAMEWORKS
The Application Framework layer provides many higher-level services to
applications in the form of Java classes. Application developers are allowed to
make use of these services in their applications.
• Runs .dex files. These files are built from .class files at compile time and
provide higher efficiency in low resource environments.
JDK
The Java Development Kit (JDK) is a software development environment
that offers a collection of tools and libraries necessary for developing Java
applications. You need the JDK to convert your source code into a format
that the Java Runtime Environment (JRE) can execute.
• The JDK includes the Java Runtime Environment (JRE), an interpreter
(java), a compiler (javac), an archiver (jar), a documentation generator
(javadoc), and some other development tools.
• The Java Runtime Environment itself consists of the Java Virtual
Machine (JVM), supporting files, and core classes.
Android
SDK
• Android SDK is a software development kit developed by Google for
the Android platform.
• Whether you create an application using Java, Kotlin or C#, you need the
SDK to get it to run on any Android device. You can also use an emulator
in order to test the applications that you have built.
• Nowadays, the Android SDK also comes bundled with Android Studio,
the integrated development environment where the work gets done and
many of the tools are now best accessed or managed.
Android SDK
SDK FEATURES
❖ No licensing,development fees,distribution
❖ Wifi hardware access
❖ Comprehensive API s design for location based services such as GPS
❖ Open source webkit based browser
❖ Media libraries
❖ IPC message passing
❖ Shared data stores
Android IDEs
There are so many sophisticated Technologies are available to
develop android applications, the familiar technologies, which are
predominantly using tools as follows
• Android Studio
• IntelliJ
• Eclipse IDE
• Testing your app on the emulator is in some ways faster and easier
than doing so on a physical device. For example, you can transfer
data faster to the emulator than to a device connected over USB.
❖ Unified environment where you can develop for all android devices
Step 1
To download the Android Studio, visit the official Android Studio website in
your web browser.
Step 2
"Android Studio Setup" will appear on the screen and click "Next" to proceed.
Step 5
Select the components that you want to install and click on the "Next" button.
Step
6
Now, browse the location where you want to install the Android Studio and
click "Next" to proceed.
Step
7
Choose a start menu folder for the "Android Studio" shortcut and click the
"Install" button to proceed.
Step 8
• The manifest file is an important part of our app because it defines the
structure and metadata of our application, its components, and its
requirements.
• This file includes nodes for each of the Activities, Services, Content
Providers and Broadcast Receiver that make the application and using
Intent Filters and Permissions, determines how they co-ordinate with each
other and other applications.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.geeksforgeeks.geeksforgeeks">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNC
HER" />
</intent-filter>
</activity>
</application>
</manifest>
• <application>…..</application> tags enclose components related to the
application.
• <activity> tag is used to specify an activity and android::name specifies the fully
qualified classname of the activity subclass.
<resources>
<string name="app_name">Hello World</string>
<string name=“menu_settings">Settings</string>
</resources>
8.styles.xml: The styles.xml file contains resources of the theme style in the
Android application. This file is written in XML language
<resources>
<!-- Base application theme. -->
<style name="AppTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item
name="colorPrimary">@color/colorPrimary</i
tem>
<item
9.build.gradle(Module: app): This defines the module-specific build
configurations.This is an autogenerated file containing compile sdk
version,build tools version,min sdk version,target sdk version,version code and
version name. Here you can add dependencies what you need in your Android
application
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.geeksforgeeks.geeksforgeeks"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEna
bled
false
proguard
Files
getDefa
ultProg
uardFil
e('prog
uard-
android
.txt'),
'progua
rd-
rules.pr
LAYOUTS
How to use layouts, fragments ,place views to create functional UI.
FAMILIARISATION OF SCREEN
COMPONENTS
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
Border layout
Card layout
Box layout
Null layout
Layout views in Android SDK
Android contains the following commonly used ViewGroupsubclasses:
1.LINEAR LAYOUT
• Android LinearLayout is a view group that aligns all children in
either vertically or horizontally.
• Simplest layout
res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button android:id="@+id/btnStartService“
android:layout_width="270dp"
android:layout_height="wrap_content"
android:text="start_service"/>
<Button
android:id="@+id/btnPauseService“
android:layout_width="270dp"
android:layout_height="wrap_content"
android:text="pause_service"/>
<Button android:id="@+id/btnStopService"
android:layout_width="270dp" android:layout_height="wrap_content"
android:text="stop_service"/>
</LinearLayout>
Attributes and
Description
Android:id- uniquely identifies the view
android:orientation—Used for arranging the controls in the container in
horizontal or vertical order
android:layout_width—Used for defining the width of a control
android:layout_height—Used for defining the height of a control android:padding
—Used for increasing the whitespace between the boundaries of the control and
its actual content
android:layout_weight—Used for shrinking or expanding the size of the control
to consume the extra space relative to the other controls in the container
android:gravity—Used for aligning content within a control
android:layout_gravity—specifies how child views are positioned
Android:layout_x-specifies x coordinate of the layout
Android:layout_y-specifies y coordinate of the layout
Android:layout_width=wrap_content tell your view to size itself to the
dimensions required by its content.
Android:layout_width=fill_parent tells your view to become as big as its parent
view
2.ABSOLUTE
LAYOUT
1 android:id
This is the ID which uniquely identifies
the layout.
2 android:layout_x
This specifies the x-coordinate of the view.
3 android:layout_y
This specifies the y-coordinate of the view.
res/layout/
activity_main.xml
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="OK"
android:layout_x="50px"
android:layout_y="361px" />
<Button android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_x="225px"
android:layout_y="361px" />
</AbsoluteLayout>
3.FRAME LAYOUT
Frame Layout is designed to allocate an area on the screen to display a single
item. Generally, FrameLayout should be used to hold a single child view, (ie a
single item once).We can have multiple elements, each element will be
positioned based on top left of screen.
You can, however, add multiple children to a FrameLayout and control their
position within the FrameLayout by assigning gravity to each child, using the
android:layout_gravity attribute.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="@mipmap/ic_launcher"
android:scaleType="fitCenter"
android:layout_height="250px“
android:layout_width="250px"/>
</FrameLayout>
Sr.No Attribute & Description
1 android:id
This is the ID which uniquely identifies the layout.
2 android:foreground
This defines the drawable to draw over the content and
possible values may be a color value, in the form of
"#rgb", "#argb", "#rrggbb", or "#aarrggbb".
3 android:foregroundGravity
Defines the gravity to apply to the foreground drawable.
The gravity defaults to fill. Possible values are top, bottom,
left, right, center, center_vertical, center_horizontal etc.
4 android:measureAllChildren
Determines whether to measure all children or just
those in the VISIBLE or INVISIBLE state when measuring.
Defaults to false.
4.RELATIVE
LAYOUT
RelativeLayout is a view group that displays child views in relative positions.
The position of each view can be specified as relative to sibling elements (such
as to the left-of or below another view) or in positions relative to the
parent RelativeLayout area (such as aligned to the bottom, left or center).
3 android:ignoreGravity
This indicates what view should not
be affected by gravity.
By default, all child views are drawn at the top-left of the layout, so you must
define the position of each view using the various layout properties available
from RelativeLayout.LayoutParams and few of the important
attributes are given below
4 android:layout_alignParentBottom
If true, makes the bottom edge of this view match the
bottom edge of the parent. Must be a boolean value,
either "true" or "false".
5 android:layout_alignParentEnd
If true, makes the end edge of this view match the
end edge of the parent. Must be a boolean value,
either "true" or "false".
6 android:layout_alignParentLeft
If true, makes the left edge of this view match the left
edge of the parent. Must be a boolean value, either
"true" or "false".
7 android:layout_alignParentRight
If true, makes the right edge of this view match the
right edge of the parent. Must be a boolean value,
either "true" or "false".
9 android:layout_centerHorizontal
If true, centers this child horizontally within its parent. Must be a boolean value,
either "true" or "false".
10 android:layout_centerInParent
If true, centers this child horizontally and vertically within its parent. Must be a
boolean value, either "true" or "false".
11 android:layout_below
Positions the top edge of this view below the given anchor view ID
12 android:layout_centerVertical
If true, centers this child vertically within its parent. Must be a boolean value,
either "true" or "false".
13 android:layout_alignParentStart
If true, makes the start edge of this view match the start edge of the parent. Must
be a boolean value, either "true" or "false".
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:paddingLeft="16dp" android:paddingRight="16dp" >
<EditText android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint=“Enter your name" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button" />
4 android:stretchColumns
The zero-based index of the columns to
stretch. The column indices must be
separated by a comma: 1, 2, 5.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="2">
<TableRow>
<TextView
android:text="OPEN"
android:padding="8dip" />
<TextView
android:text="CONTROL +0"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:text="SAVE"
android:padding="8dip" />
<TextView
android:text="CONTROL+SAVE"
android:gravity="right"
android:padding="3dip" />
</TableRow>
</TableLayout>>