MAD Model 1
MAD Model 1
MODEL PAPER - 1
SECTION - A
Example: An example of a mobile application is Instagram, a popular app for sharing photos
and videos with friends and followers. Users can upload images and videos, apply filters, and
share them on their profile or with a selected audience
Pavithra.S
"WebView' is a view that displays web pages within an Android application. It is based on the
Wes engine and allows integration of web content seamlessly into the app. 'WebView' can be
used to th static HTML content or to load web pages from the internet. It's particularly useful
for displa content hosted online or for creating hybrid applications that combine web and native
views.
In the context of Android app development, designing by declaration involves using XML files
to define the visual elements and attributes of the user interface. By separating the UI design
from the application logic, developers can achieve a more modular and maintainable codebase.
This approach allows for a clear separation of concerns, making it easier to manage and update
the UI independently of the underlying functionality
Section-B
Pavithra.S
The journey of mobile technology began in the early 20th century with the invention of radio
communication. The first real step towards mobile communication came with the development
of mobile radio telephones in the 1940s. It was primarily used in vehicles with limited coverage
and functionality
The introduction of the first-generation (1G) mobile networks in the 1980s marked the true
beginning of mobile telephony 1G networks were analog and allowed for voice communication
through mobile phones
The launch of the Motorola DynaTAC 8000X in 1983, the first commercially available mobile
phone, was a landmark event despite its large size and limited battery life
The 1990s saw the advent of the second-generation (26) mobile networks, which were
digital and offered significant improvements in voice quality and capacity 2G networks
introduced the Global System for Mobile Communications (GSM) and it
became the standard for mobile communication worldwide This era also saw the introduction of
Short Message Service (SMS) by enabling text messaging between mobile devices
The early 2000s brought the third generation (3G) mobile networks to enable faster data
Pavithra.S
It has shown the way for the development of more advanced mobile applications and services
The introduction of fourth-generation (4G) mobile networks in the late 2000s revolutionized
mobile technology with high speed internet access to enable seamless streaming of high
definition video, faster downloads, and enhanced mobile gaming experiences
Long Term Evolution (LTE) became the dominant 4G standard by offering significantly faster
data speeds and lower latency
This period also witnessed the rise of smartphones, integrating powerful processors high
resolution displays, and a wide array of sensors, transforming them into versatile tools for
communication, entertainment, and productivity
5G represents the latest advancement in mobile technology promising ultra fast speeds low
latency, and massive connectivity to support emerging technologies like Internet of Things
(IoT), augmented reality (AR), and autonomous vehicles
9. Explain DatePicker along with its attributes and features Give an example
DatePicker is a Ul component that allows users to select a specific date. It can display dates in
various lunmats and allows navigation between days, months, and years.
Pavithra.S
Example Scenario: Scheduling an appointment, setting a birthday, or selecting a due date
1. Date Selection: Allows users to select a specific date from a calendar or spinner view
2. Customizable Display: Can be displayed as a calendar or spinner, depending on the mode set
(calendarViewShown and datePicker Mode attributes)
3. Min and Max Date: Supports setting minimum and maximum selectable dates to restrict user
input to a specific range
Iittent filters are composed of three main elements: action, category, and data. Each of these
eleme plays a crucial rule in defining the scope and capability of the intent filter
1. Action: The action element represents the general action to be performed by the inte Actions
are typically predefined constants in the 'Intent class. Examples of actions include
Pavithra.S
android.intent.action.VIEW: This action indicates that an activity can display data the user. It's
commonly used for viewing web pages, images, and other types of content
"android.intent.action.SEND': This action is used to send data from one activity is another it's
often used for sharing content such as text, images, or other data
android.intent.action DIAL' This action is used to dial a number opening the diale with the
number populated
android intent.action.MAIN": This action is used to start the main activity of as application. It
signifies the main entry point of the app and is often paired with the LAUNCHER category to
display the app icon in the launcher.
android.intent.action EDIT: This action indicates that the activity can edit specified data. It's
typically used for editing contacts or calendar events.
2. Category: The category element provides additional information about the action being
performed Categories help to refine the type of component that should handle the intem Some
common categories include
"android.intent.category DEFAULT: This is the most commonly used category and indicates
that the activity can be launched by default if no other category is specified
Pavithra.S
android.intent.category. LAUNCHER': This category is used to indicate that the activity should
be listed in the system's application launcher It designates the main entry poin for the
application.
"android.intent.category HOME': This category is used for the home screen of the device
android.intent.category APP CONTACTS': This category is used for activities that desi with
contacts.
Categories are used in combination with actions to provide a more specific contest for fi intent
to ensure that the most appropriate component is chosen to handle it.
3. Data: The data element specifies the type of data that the intent is interested in. This can
Include a URI scheme, a MIME type, or both. The data element allows components to declare
their capability to handle specific types of data, such as:
URI Scheme: Specifies the protocol for accessing the data (eg. 'http', 'https', 'mailto'). This
indicates the type of data source the component can handle.
Example: 'android scheme="http" indicates that the component can handle HTTP URLS
MIME Type: Specifies the format of the data the component can handle (eg. 'image/*".
text/plain"). This allows components to specify the exact type of data they can process.
Example: 'android mimeType="image/* indicates that the component can handle any type of
image file.
Pavithra.S
10. How does a Scroll View help in handling different screen sizes in Android? Explain with an
example
11. How can an application pre fill email details like recipient, subject and body using an
Intent? Provide an example
SECTION - C
Key Features:
Code Editor: Android Studio provides a powerful code editur with features like youn
highlighting, code completion, refactoring, and code navigation to enhance productivity and
code quality
Layout Editor: The Layout Editor enables developers to create visually appealing interfaces
with drag and drop functionality, real-time previews, and support for differen screen sizes and
orientations.
Pavithra.S
SDK Manager: The Android SDK Manager is a tool within Android Studio that allows
developers to download, install, and manage different versions of the Android SDK, as well as
other essential tools and components.
Device Manager: The Device Manager is a tool within Android Studio that allows developers to
create and manage virtual devices that simulate physical Android devices These virtual devices
are used to test and debug applications on various configurations and Android versions without
needing physical devices.
APK Analyzer: Helps analyze APK size, contents, and dependencies to optimize app
performance and reduce file size
Built-in Emulator: The built-in Android Emulator allows developers to test their apps on virtual
devices with various configurations, screen sizes, and Android versions for comprehensive
testing
• Device Testing: Developers can test their apps on physical devices connected via USB for
real- world testing scenarios, in addition to the Android Emulator, to ensure app compatibility
and performance
Version Control Integration: Android Studio supports version control systems like Git, enabling
developers to manage source code, track changes, and collaborate with team members
efficiently within the IDE
Extensive Plugin Ecosystem: Android Studio offers a wide range of plugins and extensions
from the Plugin Marketplace to extend functionality, integrate with external tools, and
customize the development environment according to specific requirements.
Performance Profiling Tools: Android Studio offers performance profiling tools to analyze app
performance, identify bottlenecks, and optimize CPU, memory, and network usage for better
user experience.
Pavithra.S
Build Tools: Android Studio integrates the Gradle build system for automating build tasks,
managing dependencies, and configuring build variants to streamline the app development
proces
Integrated Debugger: An integrated debugger allows developers to identify and fix issues in
their code by setting breakpoints, inspecting variables, and stepping through code execution
b) What is the use of Android Manifest File? Explain the components (or) structure of Android
Manifest File
The AndroidManifest.xml file is a crucial component of an Android application that provides
essential information about the app to the Android system. It contains metadata about the
application, its components (such as activities, services, broadcast receivers), permissions
required, hardware and software features used, and more. It is located in the project's root
directory as AndroidManifest. xml, this file defines how different parts of the app interact with
each other and with the Android system.
. Structure for) Components of AndroidManifest.xml
The AndroidManifest.xml file is structured in a hierarchical format with nested elements. Let us
understand the components of AndroidManifest.xml
1. XML Declaration
The file starts with an XMI declaration specifying the version of XML being used.
2. <manifest> Element:
The <manifest> element is the root element of the AndroidManifest.xml file and contains
information about the application package and versioning.
Pavithra.S
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package com.example.myfirstapp
android:versionCode="1"
android:versionName-"1.0">
Attributes:
xmlns:android: The XML namespace declaration. This must be included in the roa element
package: The unique identifier for the application. This should match the package nams used in
the Java or Kotlin code
android:versionCode: An integer value that represents the version code of the application
android:versionName: A string value that represents the release version of the application,
shown to users.
3. <application> Element:
The <application element contains information about the application itself, such as its icos
label, theme, and components
capplication
android:allowBackup="true"
android:icon="@mipmap/ic launcher"
Pavithra.S
android:label="@string/app_name"
android:supportsRt1-"true"
android:theme="@style/AppTheme">
Attributes:
layouts
4. <activity> Element:
Inside the <application>' element, <activity>' elements define the activities in the application.
Each <activity> element represents a screen with a user interface.
cactivity android:name=".MainActivity">
Pavithra.S
cintent-filter>
</intent-filter>
</activity:
Attributes:
<intent-filter> Defines the intent filters for the activity, specifying how it can be launched. The
example shows an activity that responds to the MAIN action and LAUNCHER category,
making it the entry point of the application.
5. Services: <service>
Attributes:
Pavithra.S
6. Broadcast Receivers: <receiver>
Declares a broadcast receiver, which allows the application to listen for system-wide broadcast
announcements.
Attributes:
Attributes:
Pavithra.S
The <uses-permission element is used to declare permissions required by the application to
access certain features or resources.
Attributes:
INTERNET)
9. Features: <uses-feature>
Declares the hardware and software features used or required by the application.
Attributes:
14. a) How to create a style and theme in android? Explain with an example
The styles and themes are powerful tools to define and apply consistent visual styles across an
application or specific components like activities. Understanding styles and themes is essential
for creating a visually appealing user interface.
1. Styles:
Pavithra.S
Definition: A style in Android is a collection of properties that specify the look and format for a
View or a window It can be used to share common attributes across multiple elements to ensure
a consistent look and feel throughout the application
Usage: Styles can be applied to individual views in layout XML files or set programmatically in
Java/Kotlin code
Purpose:
+ Reusability: Styles enable the reuse of a set of properties across different U components to
promote a consistent design and reducing redundancy,
+ Customization: They allow for easy customization and updates Changing a style definition
updates all components using that style.
Components:
+ Style Resource: Defined in an XML file under the res/values directory, typically in
themes.xml
+ Attributes: Consist of key-value pairs that define various properties like layout width, layout
height, textColor, background, etc.
2. Themes:
Definition: A theme in Android is a style applied to an entire Activity or application rather than
an individual View Themes are used to define the look and feel of all elements within the scope
they are applied to. Themes can include styles for various U components like buttons, text
fields, dialogs, etc.
Pavithra.S
Purpose:
+ Global Consistency: Themes ensure a uniform appearance across the entire application or
specific activities
+ Customization: They allow for the definition of global attributes such as color palettes, font
styles, and dimensions, which can be easily changed in one place
• Components:
+ Theme Resource: The themes are defined in themes.xml file within the res values directory
+ Inheritance: Themes can inherit properties from other themes, allowing for hierarchical and
layered customization.
Application Level vs. Activity Level: Themes can be applied at the application level in the
AndroidManifest.xml file or at the activity level in layout XML files.
Customization: Themes can be customized to create unique visual experiences for different
parts of the application.
Example
to define a simple style for a button and a theme for the s the layout, and the theme is set for Do
nangle demonstrates hone to the button in applied application. The style the entire application
in the manifest file. This
Pavithra.S
a consistent look and feel with minimal code Stop 1: Create Colors in colors.xml
3.13
Define the colors to be used in the style and theme in coloriamd file located under res/values
holder
Code
<resources>
colors.xml
color name="colorPrimary">#6200EE</color>
<color name="colorAccent">#03DACS</color>
</resources>
Deline a single style and theme for demonstration purposes in themes.xml file located under
res/
value/themes/themes.xml
Code
(resources>
Pavithra.S
themes.xml
</style>
<item name="android:background">@color/colorAccent</item>
<iten name="android:textColor">#FFFFFF</item>
<item name="android:padding">10dp</item>
</style>
</resources>
Pavithra.S
Apply the defined style to a button in acivity main.xml file located under res/layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout width="match_parent"
android:layout_height="match_parent"
android:id="@+id/button"
style="@style/CustomButtonStyle"
android:text="Click Me"
android:layout_centerInParent="true"/>
</RelativeLayout>
Set the theme for the entire application in the AndroidManifest.xml file.
Pavithra.S
Code
AndroidManifest.xml
package com.example.myfirstapp">
<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">
<intent-filter>
</intent-filter>
Pavithra.S
</activity>
</application>
</manifest>
Code
MainActivity.java
package com.example.myfirstapp;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
@Override
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Pavithra.S
1. Set Up the Project: Create a new Android project in Android Studio.
2. Create the Fragment Class: Define a fragment class that will be added dynamically
3. Create Fragment Layout: Define the layout XML file for the fragment.
4. Modify the Activity Layout: Add a container (FrameLayout) in the activity's layout file
where the fragment will be dynamically added.
15. List and briefly describe common views used in Android applications with their XML
definitions
Some common views used in Android applications, along with their XML definitions are given
below. These views are essential components in creating interactive and user-friendly interfaces
in Android applications. Each view type has its own unique attributes and behaviors, allowing
for flexible and dynamic Ul design.
1. TextView:
Description:
Code
<TextView
Pavithra.S
android:layout_width="wrap_content"
android:textSize="20sp"
android:textColor="#000000"/>
Explanation
android:layout, width="wrap content"" The width of the TextView will be just enough to fit the
content.
android:layout height="wrap_content"": The height of the TextView will be just enough to fit
the content
2. Button:
Description:
A push-button that can be pressed or clicked by the user. Used to perform actions when clicked.
Code
<Button
Pavithra.S
android:layout width="wrap_content" android:layout height="wrap_content"
android:text="Click Me"/>
Explanation
android:layout width="wrap content"": The width of the Button will be just enough to fit the
content
android layout height="wrap content" The height of the Button will be just enough to fit the
content.
3. EditText:
Description:
Code
<EditText
android:layout_width="match_parent"
android:layout height="wrap_content"
android:hint="Enter text"/>
Pavithra.S
Explanation
android:layout, width="match parent"": The width of the EditText will expand to match the
width of its parent container
android:layout height="wrap.content". The height of the Edir Text will be just enough to fit the
content.
android hint="Enter text Sets a hint that is displayed when the EditText is empty, promptag the
user for input
4. ImageView:
Description:
Code
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/sample_image"/>
Explanation
Pavithra.S
'android layout, width="wrap content". The width of the Image View will be just enough to the
content
android:layout height="wrap content": The height of the Image View will be just enough to the
content.
. CheckBox
• Description:
Code
CheckBox
android:layout width="wrap_content"
android:layout height="wrap_content"
android:text="Check me"/>
Explanation
Pavithra.S
android layout width="wrap content": The width of the CheckBox will be just enough to fit the
content.
android layout height="wrap content" The height of the CheckBox will be just enough to fit the
content
6. RadioButton:
Description:
A radio button, usually used in a group where only one option can be selected at a time
Commonly used in forms where a single choice must be made from multiple options.
Code
<RadioButton
android:layout width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 1"/>
Explanation
android layout width="wrap content: The width of the RadioButton will be just enough to fit
the content.
Pavithra.S
android layout height="wrap content"". The height of the RadioButton will be just enough to fit
the content
?f
Anchoring views in Android layout design refers to the technique of fixing the position of Ul
elements relative to specific edges or positions on the screen. By anchoring views, we can
ensure that certain elements remain in a consistent location regardless of changes in screen
orientation to provide a stable and predictable layout for the user interface.
How It Works?
In Android XML layouts, anchoring views is typically achieved using a RelativeLayout, which
allows to define the position of views relative to the parent layout or other sibling views. By
setting the below attributes, we can anchor views to specific edges of the screen.
Anchoring Attributes:
Pavithra.S
1. 'android:layout alignParentBottom': This attribute positions the view at the bottom edge of its
parent layout. When set to "true", the view will be anchored to the bottom of the parent layout
to ensure it remains at the bottom regardless of other views or screen orientation changes
2. 'android:layout_alignParentLeft': Setting this attribute to "true" aligns the view with the lett
edge of its parent layout. The view will be anchored to the left side of the parent, maintaining
its position relative to the left edge even if other views are added or the screen orientation
changes
4. 'android:layout alignParentTop': When this attribute is set to "true", the view is aligned with
the top edge of its parent layout. Anchoring the view to the top ensures it stays at the top of the
parent layout, maintaining its position regardless of other elements or orientation adjustments.
When the device orientation changes. Android destroys the current activity and creates a new
instance of it. This process is essential to reload resources that match the new configuration,
such as different layout files optimized for landscape or portrait mode
During this process, the 'onCreate() method is called again, setting up the new activity instance.
This ensures that the activity is correctly configured for the new orientation, but it also means
that the activity starts from scratch, losing any transient Ul state unless it's explicitly saved and
restored
Pavithra.S
Example: Imagine an email application where a user is composing an email. If the user changes
the device orientation while typing, the activity is destroyed and recreated: Without proper
handling, the user might lose the text they were typing, which can be frustrating and disruptive
Transient Ul states, such as text entered in text fields, selected items in lists, and other
temporary data, can be lost during the destruction process. This happens because the default
behavior does not automatically save this transient state
Any unsaved data is discarded when the activity is destroyed. The new activity instance created
after the orientation change will not have access to the previous state unless mechanisms are in
place to save and restore in.
Example: Consider a shopping app where a user is filling out a checkout form. If the user
rotates the device mid-process, all the information entered into the form fields could be lost,
requiring the user to start over. This could lead to user frustration and potentially abandonment
of the checkout process.
3. Persisting State:
To preserve the activity state across configuration changes. Android provides several
mechanisms
onSaveInstanceState() Method: This method allows the activity to save its current Ul state into
a Bundle before it is destroyed. When the activity is recreated, the saved state can be restored
from the Bundle
onRestoreInstanceState() Method: This method can be used to restore the state from the Bundle
that was saved in onSaveInstanceState(). It provides an opportunity to restore the Ul state after
the onCreate() method has completed
Pavithra.S
Example: in a note-taking app, a user may be writing a note. If the orientation changes, the app
should save the current note's text using the 'onSaveInstanceState() method. When the activity
is recreated, the app retrieves the text from the 'Bundle' and restores it in the text field.
17. Explain the complete workflow of creating, reading, updating, and deleting data in a SQLite
database with code examples.
Pavithra.S