KEMBAR78
Unit 1 Notes | PDF | Android (Operating System) | Mobile App
0% found this document useful (0 votes)
41 views42 pages

Unit 1 Notes

The document provides an overview of mobile application development, comparing web and mobile apps, and outlining the stages of development. It details the evolution of mobile technologies from 1G to 5G, describes mobile operating systems and frameworks, and highlights key features and services in mobile applications. Additionally, it discusses emerging technologies such as AI, IoT, and mobile development tools, with a focus on Android's history and key aspects of its application development.

Uploaded by

mythris107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views42 pages

Unit 1 Notes

The document provides an overview of mobile application development, comparing web and mobile apps, and outlining the stages of development. It details the evolution of mobile technologies from 1G to 5G, describes mobile operating systems and frameworks, and highlights key features and services in mobile applications. Additionally, it discusses emerging technologies such as AI, IoT, and mobile development tools, with a focus on Android's history and key aspects of its application development.

Uploaded by

mythris107
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

UNIT 1

MOBILE APPLICATION DEVELOPMENT


Mobile application development is essentially the process of creating software applications that
are designed to run on mobile devices, such as smartphones and tablets.
Web Application vs Mobile Application

Feature Web Apps Mobile Apps (Native)


Accessed through a web Downloaded and installed from an app store
Access browser (e.g., Chrome, Safari) (e.g., App Store, Google Play)
Installation No installation required Requires installation on the device
Cross-platform; works on any
Platform device with a browser Platform-specific (iOS or Android)
Uses web technologies Uses platform-specific languages
Development (HTML, CSS, JavaScript) (Swift/Objective-C, Kotlin/Java)
Development
Cost Generally lower cost Generally higher cost
Dependent on browser and Generally better performance; direct access
Performance internet connection to hardware
Limited or requires internet
Offline Access connection Can offer offline functionality
Device Limited access to device
Features hardware (camera, GPS) Full access to device hardware
Updates are server-side, Updates through app store, requires user
Updates immediate download
Accessed through URLs and
Distribution search engines Distributed through app stores
User dependent on the quality of the Tends to be a more fluid and integrated user
Experience responsive web design. experience.

STAGES OF MOBILE APPLICATION DEVELOPMENT:


1. Planning
2. Design
3. Development
4. Testing
5. Deployment
6. Maintenance and Updates

BRIEF HISTORY OF MOBILE TECHNOLOGIES:


• 1982: First Generation (1G — analog voice only) systems with large heavy phones and
poor network quality were introduced.
• 1992: Second Generation (2G) was deployed with improvements in signaling and
hardware that were primarily aimed toward the voice market but, unlike the first-
generation systems, used digital modulation to enhance call quality and enable new
applications such as Short Messaging Services (SMS) and other low-data-rate (9.6 to
237 kbps) wireless applications.
• 2001: Third Generation (3G) was introduced, providing a significant leap over 2G, with
much higher data rates (typically ranging from 400 Kbps to 16 Mbps), significant
increases in network voice capacity, along with better channel quality and — most
important — support for advanced services and applications, including multimedia.
• 2012: Fourth Generation (4G) was deployed (some call it 4G-LTE). This was an all IP-
network with increased speeds ranging from 21 Mbps to 1 gigabit speeds with wireless
network latencies of 5 milliseconds. The wireless service providers were able to reduce
network-per-megabyte costs with this new technology, while responding to increasing
bandwidth demands from subscribers. One of the goals of LTE was to make the mobile
Internet experience as good as or better than that offered by the wired broadband access
systems deployed today.
• 2020: 5G is the fifth-generation mobile network, offering significantly faster speeds
and lower latency. It enables enhanced mobile broadband, supporting applications like
high-definition streaming and online gaming. Its increased capacity powers the Internet
of Things, connecting numerous devices. 5G is crucial for emerging technologies like
autonomous vehicles and remote surgery. Ultimately, it aims to revolutionize various
industries with its improved connectivity and responsiveness.

MOBILE TECHNOLOGIES
• It is a type of technology in which a user utilizes a mobile phone to perform
communications-related tasks, such as communicating with friends, relatives, and
others. It is used to send data from one system to another. Portable two-way
communications systems, computing devices, and accompanying networking
equipment make up mobile technology.
• Mobile technology is largely employed in cellular communication systems and other
related areas. It employs a network architecture that allows multiple transmitters to
deliver data on a single channel at the same time. Because it reduces the potential of
frequency interference from two or more sources, this platform allows multiple users
to use single frequencies. The channel has evolved over time.

CELLULAR NETWORKS
Cellular networks have progressed through several generations, each bringing significant
improvements in speed, capacity, and capabilities. Here's a breakdown of the main types:
• 1G (First Generation):
o Analog cellular technology.
o Primarily for voice calls.
o Limited capacity and poor voice quality.
o Example: AMPS (Advanced Mobile Phone System).
• 2G (Second Generation):
o Digital cellular technology.
o Introduced text messaging (SMS).
o Improved voice quality and security.
o Examples: GSM (Global System for Mobile Communications), CDMA (Code
Division Multiple Access).
• 3G (Third Generation):
o Brought mobile data and internet access.
o Enabled multimedia messaging (MMS) and video calls.
o Improved data speeds compared to 2G.
o Examples: UMTS (Universal Mobile Telecommunications System),
CDMA2000.
• 4G LTE (Fourth Generation Long-Term Evolution):
o Focused on high-speed mobile broadband.
o Enabled faster downloads and streaming.
o Improved network capacity and efficiency.
o LTE-Advanced further increased speeds.
• 5G (Fifth Generation):
o Offers significantly faster speeds, lower latency, and greater capacity.
o Supports a wide range of applications, including IoT, autonomous vehicles, and
virtual reality.
o Has varying levels of speed, and coverage, depending on the frequencies
utilized.

MOBILE OPERATING SYSTEM


A mobile operating system (OS) is the software platform that runs on mobile devices like
smartphones, tablets, and smartwatches. It manages the device's hardware and software
resources, providing a foundation for applications to run. Here's a more detailed look:

Key Functions of Mobile Operating System:

• Hardware Management:
• Application Management:
• User Interface (UI):
• Networking and Connectivity:
• Security:
• File Management:

Key Mobile Operating Systems:

• Android:
o Developed by Google.
o Open-source and highly customizable.
o Widely used on a variety of devices from numerous manufacturers.
• iOS:
o Developed by Apple.
o Exclusively used on Apple devices (iPhones, iPads).
o Known for its user-friendly interface and tight integration with Apple hardware.
• Others (Less Common):
o While Android and iOS dominate, there are other operating systems that have
existed, or exist for very niche applications.

MOBILE DEVELOPMENT FRAMEWORKS:

1. Cross-Platform Frameworks:

• React Native:
o Developed by Facebook (Meta).
o Uses JavaScript and React to build native-like apps for iOS and Android.
o Known for its "learn once, write anywhere" approach.
• Flutter:
o Developed by Google.
o Uses the Dart programming language.
o Creates high-performance, visually appealing apps for iOS, Android, web, and
desktop from a single codebase.
• Xamarin:
o Developed by Microsoft.
o Uses C# and .NET to build native apps for iOS and Android.
o Allows for code sharing across platforms.
• Ionic:
o Builds hybrid apps using web technologies (HTML, CSS, JavaScript).
o Uses Cordova or Capacitor to access native device features.
2. Native Development Frameworks (Platform-Specific):

• iOS (SwiftUI/UIKit):
o SwiftUI is Apple's modern UI toolkit for building declarative interfaces.
o UIKit is the older, imperative UI framework.
o Both are used with Swift or Objective-C.
• Android (Android SDK/Jetpack Compose):
o Android SDK provides tools and libraries for building Android apps using Java
or Kotlin.
o Jetpack Compose is Android's modern toolkit for building native Android UI.

MOBILE WEB TECHNOLOGIES:

HTML5:

• Role: The latest version of HTML, providing enhanced multimedia capabilities,


offline storage, and improved form handling.
• Benefits: Enables richer web applications with features like video and audio
playback, geolocation, and canvas drawing.

Progressive Web Apps (PWAs):

• Concept: Web applications that offer a native app-like experience on mobile devices.
• Technologies: Service workers, web app manifests, and HTTPS.
• Benefits: Offline functionality, push notifications, and home screen installation.

CONNECTIVITY AND COMMUNICATION:

Cellular Networks (4G, 5G):

• Enable mobile apps to access the internet and communicate over long distances.
• Essential for apps that require real-time data, such as social media, navigation, and
streaming.

Wi-Fi:

• Provides faster and more stable internet connections, particularly in indoor


environments.
• Crucial for apps that handle large amounts of data, such as video streaming and file
downloads.

Bluetooth:

• Enables short-range wireless communication between devices.


• Used for connecting peripherals, such as headphones, smartwatches, and IoT devices.
NFC (Near Field Communication):

• Allows for short-range, high-frequency communication, often used for contactless


payments and data transfer.

Ex: Google pay and Apple pay

SENSORS AND HARDWARE INNOVATIONS:

Touchscreen Enhancements:

• Improved sensitivity and responsiveness for smoother interactions.


• Pressure-sensitive touch (3D Touch) for contextual menus and actions.

Biometric Sensors:

• Fingerprint scanners and facial recognition for secure authentication and personalized
experiences.
• Heart rate sensors and other health-related sensors for fitness and wellness apps.
• Ex: Apple Face ID, Samsungs’s heart rate monitor.

Motion Sensors (Accelerometers, Gyroscopes):

• Enabling motion-based gaming, augmented reality experiences, and step tracking.


• Automatic screen rotation and gesture recognition.
• Ex: Fitness App, Gaming App

LOCATION-BASED SERVICES(LBS):

GPS (Global Positioning System): Provides accurate location data using satellite signals.

Ex: Google Maps, Apple Maps

Geofencing

1. Triggering actions or notifications when a user enters or exits a specific area.


2. Used for targeted advertising, security alerts, and smart home automation.

Ex: Location-Based Marketing, Smart Home Automation.

CLOUD STORAGE

Ex: Google drive, iCloud, Dropbox


EMERGING TECHNOLOGIES:

1. Augmented Reality (AR) and Virtual Reality (VR):

• AR Apps: Overlays digital information onto the real world, enhancing user experiences
in gaming, retail, education, and more.
• VR Apps: Creates immersive virtual environments for gaming, training, and
entertainment.
• Spatial Computing: Combining AR/VR with sensors and AI to create more interactive
and immersive experiences.

2. Internet of Things (IoT):

• Smart Home Integration: Mobile apps can control and monitor IoT devices in smart
homes.
• Wearable Device Connectivity: Apps can connect to and interact with wearable
devices, such as smartwatches and fitness trackers.
• Industrial IoT (IIoT): Mobile apps can be used for remote monitoring and control of
industrial equipment.

ARTIFICIAL INTELLIGENCE(AI) IN MOBILE:

• Personalization: AI/ML algorithms enable apps to provide personalized


recommendations, content, and experiences.
• Voice Recognition and Natural Language Processing (NLP): Voice assistants,
chatbots, and voice-enabled interfaces are becoming increasingly prevalent.
• Image Recognition and Computer Vision: Apps can analyze images and videos for
various purposes, such as object detection, facial recognition, and augmented reality.
• Predictive Analytics: Apps can analyze user data to predict future behavior and
provide proactive services.
• Virtual Assistants: They are AI-powered applications that perform tasks and provide
information based on voice commands.

Ex: Siri, Google Assistant, Amazon Alexa

USE OF MOBILE TECHNOLOGY


The incorporation of mobile technology into business has aided telecollaboration. Now,
people could connect from anywhere using mobile technology, and access the papers
and documents they need to complete collaborative work.
Work is being redefined by mobile technologies. Employees are no longer confined to
their desks; they can work from anywhere in the world.
KEY MOBILE APPLICATION SERVICES:
Key mobile application services include:
1. User Authentication & Security
• Single Sign-On (SSO)
• Multi-Factor Authentication (MFA)
• Biometric authentication (fingerprint, face recognition)
• Data encryption & secure storage
2. Push Notifications & Messaging
• Real-time push notifications
• SMS & in-app messaging
• Email alerts
3. Cloud Storage & Data Syncing
• Cloud backup & restore
• Cross-device data synchronization
• Offline access
4. Location-Based Services
• GPS tracking & navigation
• Geofencing
• Location sharing
5. Payment & In-App Purchases
• Mobile wallets (Apple Pay, Google Pay)
• Payment gateway integration (PayPal, Stripe)
• Subscription management
6. Media & Content Streaming
• Video & audio streaming
• Cloud-based media storage
• Downloadable content
7. AI & Personalization
• AI-powered recommendations
• Chatbots & virtual assistants
• Sentiment analysis
8. Analytics & Performance Monitoring
• User behavior tracking
• Crash reporting & debugging
• App usage statistics
9. Social Media & Sharing
• Social media login & sharing
• Community & user engagement features
• Live streaming
10. IoT & Smart Device Integration
• Smart home device control
• Wearable tech support
• Sensor data collection
BRIEF HISTORY OF ANDROID:
2003: Origins: Android Inc. is founded by Andy Rubin, Rich Miner, Nick Sears, and Chris
White, initially aiming to develop an operating system for digital cameras.
2005: Google Acquisition: Google acquires Android Inc., recognizing its potential for
mobile devices.
2007: Open Handset Alliance: Google announces the Open Handset Alliance, a consortium
of hardware, software, and telecommunications companies dedicated to advancing open
standards for mobile devices.
2008: Android 1.0 (Apple Pie): The first commercial Android device, the HTC Dream, is
released, running Android 1.0.
2009-2019: Rapid Growth: Android undergoes numerous updates, with version names
based on desserts (Cupcake, Donut, Eclair, etc.). These updates bring significant
improvements in features, performance, and user interface.
2019: Android 10: Google moves away from dessert names, launching Android 10 with a
focus on privacy and security.
Present: Android continues to be the world's most widely used mobile operating system,
powering billions of devices and constantly evolving with new features and technologies.

KEY FEATURES OF ANDROID:

• Open Source:
o Android's open-source nature allows manufacturers and developers to
customize the OS, leading to a wide variety of devices and applications.
• Customization:
o Users can personalize their devices with widgets, themes, and launchers,
tailoring the experience to their preferences.
• Wide App Ecosystem:
o The Google Play Store offers a vast library of applications, catering to diverse
needs and interests.
• Notifications:
o Android's notification system provides timely alerts and updates, keeping
users informed.
• Integration with Google Services:
o Seamless integration with Google services like Gmail, Maps, Drive, and
YouTube enhances productivity and convenience.
• Multitasking:
o Android's multitasking capabilities allow users to run multiple apps
simultaneously, improving efficiency.
• Widgets:
o Widgets provide at a glance information, and quick access to application
functions, directly on the home screen.
• Accessibility Features:
o Android includes accessibility features for users with disabilities, such as
screen readers, magnification tools, and captioning options.
• Hardware Diversity:
o Android runs on a wide range of devices, from budget-friendly smartphones to
high-end tablets and wearables.
• Connectivity:
o Android supports various connectivity options, including Wi-Fi, Bluetooth,
and cellular networks, ensuring seamless communication.
• Security:
o Google regularly releases security updates to protect devices from malware
and vulnerabilities.

KEY ASPECTS OF ANDROID APPLICATION DEVELOPMENT INCLUDE:

Programming Languages

• Kotlin (official language)


• Java (older but still widely used)
• Dart (for Flutter-based apps)
• C++ (for performance-critical apps using NDK)

Development Tools

• Android Studio (official IDE)


• Gradle (build automation)
• Emulator (for testing)
• Firebase (for backend services)

Android SDK (Software Development Kit)

• Libraries for UI, networking, database, etc.


• Jetpack components (LiveData, ViewModel, Navigation)
• Android Jetpack Compose (for modern UI development)

User Interface Design

• XML Layouts & Jetpack Compose


• Material Design Guidelines
• Adaptive UI (supporting multiple screen sizes)

Testing and Debugging

• Unit testing (JUnit, Mockito)


• UI testing (Espresso)
• Debugging tools (Logcat, Profiler)

Publishing

• Google Play Store guidelines


• APK/AAB generation & signing
• Monetization strategies (Ads, in-app purchases)

Continuous Updates and Maintenance

• Version control (Git, GitHub/GitLab)


• Crash analytics (Firebase Crashlytics)
• Performance monitoring and user feedback
ARCHITECTURE OF ANDROID:

Layers of Android Architecture:

1. Linux Kernel (Lowest Layer)


o Manages hardware interaction (CPU, memory, device drivers)
o Provides security, power management, and process management
o Includes drivers for display, camera, Bluetooth, etc.
2. Hardware Abstraction Layer (HAL)
o Acts as an interface between hardware and the higher layers
o Contains hardware-specific libraries for cameras, audio, sensors, etc.
3. Native Libraries & Android Runtime (ART)
o Native Libraries: C/C++ libraries for graphics (OpenGL, Vulkan), database
(SQLite), web rendering (WebKit)
o
Android Runtime (ART): Runs Android apps with features like Just-In-Time
(JIT) and Ahead-Of-Time (AOT) compilation
4. Application Framework
o Provides APIs for developers to build applications
o Includes system services like Activity Manager, Content Providers, and
Notification Manager
5. Applications (Top Layer)
o Apps built by developers and pre-installed system apps (Phone, Contacts,
Messages, etc.)
o Uses components like Activities, Services, Broadcast Receivers, and Content
Providers.

ANDROID APPLICATION COMPONENTS

1. Activities
• Represents a single screen with a user interface.
• Manages user interactions (e.g., LoginActivity, MainActivity).
• Uses the lifecycle methods (onCreate(), onStart(), onResume(), etc.).
2. Services
• Background processes that run independently of UI.
• Used for tasks like playing music, downloading files, and syncing data.
• Can be started (startService()) or bound (bindService()).
3. Broadcast Receivers
• Listens for system-wide or app-specific broadcasts (e.g., battery low, network change).
• Can be used for event-driven actions like sending notifications.
• Registered in AndroidManifest.xml or dynamically in code.
4. Content Providers
• Manages shared app data (e.g., contacts, media files, settings).
• Enables data sharing between apps using URIs.
• Implements CRUD operations (query(), insert(), update(), delete()).
5. Fragments
• A modular UI component that can be reused in multiple activities.
• Helps in designing responsive UIs for different screen sizes.
• Has its own lifecycle (onAttach(), onCreateView(), onResume(), etc.).
6. View & ViewGroups
• View: UI components (e.g., Button, TextView, ImageView).
• ViewGroup: Containers that hold Views (e.g., LinearLayout, RelativeLayout).
7. Intents
• Messaging objects that enable communication between components.
• Explicit Intent: Directly specifies the target component (e.g., open a new activity).
• Implicit Intent: Requests an action without specifying a component (e.g., share an
image).
8. Android Manifest (AndroidManifest.xml)
• Declares app components, permissions, and metadata.
• Defines app entry points (e.g., MainActivity with <intent-filter>).
• Requests necessary permissions (e.g., Internet, Camera, Location).

EXPLORING THE DEVELOPMENT ENVIRONMENT:


1. Android SDK: The Android SDK is a set of tools, libraries, and APIs required to build,
test, and debug Android apps.
Key Components of Android SDK
SDK Tools – Tools for compiling and debugging apps.
Platform Tools – Includes adb, fastboot, and other utilities.
Build Tools – Responsible for code compilation and APK generation.
System Images – Required for running emulators.
Android Support Libraries – Jetpack libraries for UI, networking, and database.

2. Android Studio: Android Studio is the official Integrated Development


Environment (IDE) for Android development, based on IntelliJ IDEA.
Features
Code Editor – Smart suggestions, auto-complete, and syntax highlighting.
Layout Editor – Drag-and-drop UI builder for XML layouts.
Gradle Build System – Automates builds and dependency management.
Emulator & Debugging Tools – Test apps in different environments.
Performance Profilers – Analyze memory, CPU, and network usage.

3. Android Emulator: The Android Emulator allows you to simulate an Android device
on your computer to test apps without a physical phone.
Features of the Emulator
Simulates phone behavior (calls, SMS, GPS, battery).
Tests UI on different screen sizes and resolutions.
Supports multiple API levels (Android 12, 13, 14, etc.).

4. Android Debug bridge: The Android Debug Bridge (adb) is a command-line tool
that allows developers to communicate with an Android device or emulator. It is
useful for debugging, installing APKs, and running shell commands.
Functions of ADB
Device Connection and Management:
ADB allows you to connect and communicate with Android devices via USB or Wi-
Fi.
File Transfer and Management:
ADB enables transferring files between your computer and the Android device.
App Installation and Management:
You can install APK files on the device using adb install.
Shell Access and System Control:
ADB provides direct shell access to execute commands on the Android device.
Debugging and Log Monitoring:
ADB includes powerful debugging tools like adb logcat, which provides real-time
system logs.

5. Gradle: Gradle is a powerful build automation tool used primarily for Java, Kotlin,
and Android development. It is designed to automate the process of compiling, testing,
packaging, and deploying applications.

Key Features of Gradle:

Declarative and Script-Based Build System: Gradle uses Groovy or Kotlin DSL to
define build scripts.
Incremental Builds for Better Performance
Gradle intelligently tracks changes and only rebuilds modified parts of the project.
Dependency Management
Gradle integrates with repositories like Maven Central, JCenter, and custom
repositories to manage dependencies.
Multi-Module and Multi-Project Support
Gradle can efficiently handle large projects with multiple modules or sub-projects.

REQUIRED TOOLS FOR ANDROID APPLICATION DEVELOPMENT

To set up Android Studio and start developing Android apps, you need several essential tools
and components. Below is a list of the required tools:
1. Android Studio IDE
• The official Integrated Development Environment (IDE) for Android development.
• Provides a code editor, UI designer, emulator, and debugging tools.
2. Java Development Kit (JDK)
• Required to run and compile Java/Kotlin code in Android Studio.
• JDK 11 or later (Android Studio now comes with an embedded JDK).
Check Installation:
java -version
3. Android SDK (Software Development Kit)
• Contains essential tools for building Android apps, including platform APIs, system
images, and build tools.
Includes:
SDK Tools
SDK Platform
Emulator System Images
Android Debug Bridge (ADB)

4. Gradle Build System


• Automates the build process, compiles code, manages dependencies, and generates
APKs.
• Comes bundled with Android Studio.
Check Version:
gradle -v
5. Android Emulator or Physical Device
• Allows testing apps on different Android versions and screen sizes.
Options:
Android Emulator (comes with Android Studio)
Real Android Device (requires USB debugging enabled)
6. Git (Version Control)
• Helps manage project versions, collaborate with teams, and push code to repositories
like GitHub.
To develop Android apps, ensure you have:
Android Studio (IDE)
Java Development Kit (JDK)
Android SDK (via SDK Manager)
Gradle (Build System)
Emulator or Real Device
Git for Version Control

STEPS TO INSTALL ANDROID STUDIO ON WINDOWS

Android Studio is the official Integrated Development Environment (IDE) for Android
development. Follow the steps below to install it on your system.

1. Download Android Studio

• Go to the official website: Android Studio Download


• Click the Download button and accept the license agreement.
• Choose the correct version for your operating system (Windows, macOS, or Linux).

2. Install Android Studio

Windows Installation

1. Run the Installer


o Locate the downloaded .exe file and double-click to run it.
2. Follow the Setup Wizard
o Click Next and install the required components.
3. Choose Installation Path
o Select a folder for installation (default is recommended).
4. Install Android SDK, Emulator, and Tools
o Select the components to install (keep defaults checked).
5. Complete Installation
o Click Finish, and Android Studio will launch.
3. Set Up Android Studio

1. Start Android Studio


o On first launch, it will ask for settings import. Choose Do not import settings
if you're installing it for the first time.
2. Download Required Components
o The Setup Wizard will guide you to install Android SDK, Emulator, and
other essential tools.
3. Choose Theme
o Select a theme (Light or Dark mode).
4. Finish Setup
o Click Finish, and Android Studio is ready to use!

4. Verify Installation

1. Open Android Studio and create a new project.


2. Run the Android Emulator or connect a real device for testing.

EXPLORING THE ANDROID STUDIO IDE

Android Studio is a powerful IDE with multiple tools to help you develop Android
applications efficiently. Here’s a breakdown of its key components and how to navigate
them.

1. Welcome Screen

When you launch Android Studio, you'll see the Welcome Screen with options to:
Start a New Project
Open an Existing Project
Access Settings & Plugins
View recent projects

2. Main Window Overview

Once you open a project, the main window is divided into several sections:

(a) Toolbar

• Located at the top of the window.


• Contains essential options like:
o Run App (to launch on emulator or device)
o Debug App (for testing & fixing errors)
o AVD Manager (Android Virtual Devices for emulation)
o Sync Gradle (to reload dependencies)

(b) Project View

• Located on the left panel.


• Helps you navigate project files.
• Common folder structure:
o manifests/ → Contains AndroidManifest.xml
o java/ → Contains your Kotlin/Java code
o res/ → Holds UI resources (layouts, images, themes)
o Gradle Scripts/ → Dependency & build configuration

(c) Code Editor

• The center of the screen where you write code.


• Features:
o Syntax highlighting (color-coded keywords)
o Autocomplete suggestions (press Ctrl + Space)
o Code navigation (use Ctrl + Click on functions/classes)

(d) Design Editor (Layout XML)

• Used to design UI screens visually.


• Two views:
1. Design Mode → Drag and drop UI elements.
2. Code Mode → Edit the XML directly.
• Switch between these using the tabs at the top-right.

(e) Logcat (Debugging Console)

• Found at the bottom of the window.


• Displays error logs, app crashes, and system messages.
• Use it to debug and find issues in your app.

(f) Emulator (Virtual Device)

• Found under Tools > Device Manager.


• Lets you run and test your app on a virtual Android device.

3. Key Features to Explore

Gradle Build System → Manages dependencies & project settings.


Theme Editor → Customize UI themes (under res/values/themes.xml).
Navigation Component → Handle screen transitions efficiently.
Database Management → Use Room, SQLite, or Firebase for data storage.
Performance Profiler → Analyze CPU, memory, and network performance (View > Tool
Windows > Profiler).

5. Running & Debugging an App

1. Click Run (or press Shift + F10).


2. Select an Emulator or Real Device (via USB).
3. Check Logcat for any issues.
4. Use Debug Mode (Shift + F9) to find bugs.

CREATING A VIRTUAL DEVICE IN ANDROID STUDIO:

Steps to Create a Virtual Device (Emulator) in Android Studio

1. Open AVD Manager → Go to Tools > Device Manager and click + Create Device.
2. Select a Device Model → Choose a phone model (e.g., Pixel 6) and click Next.
3. Choose a System Image → Select an Android version (download if needed) and
click Next.
4. Configure Settings → Adjust RAM, storage, and graphics settings if needed.
5. Finish Setup → Click Finish to create the virtual device.
6. Start the Emulator → Click (Play) in the Device Manager to launch the emulator.
7. Run Your App → Click Runs in Android Studio and select the virtual device.

TESTING ON A PHYSICAL DEVICE:

Steps to Test an Android App on a Physical Device

1. Enable Developer Options → Go to Settings > About Phone > Tap Build Number
7 times.
2. Enable USB Debugging → Go to Settings > Developer Options > Enable USB
Debugging.
3. Connect Your Device → Use a USB cable and Allow USB Debugging when
prompted.
4. Verify in Android Studio → Open Tools > Device Manager and check if your
device is detected.
5. Install USB Drivers (Windows Only) → If the device is not recognized, install the
OEM USB driver.
6. Run the App → Click Run ▶ in Android Studio, select your device, and launch the
app.
7. Debug & Test → Use Logcat, breakpoints, and real-world testing for performance
checks.
DEBUGGING TOOLS IN ANDROID STUDIO

1. Debugger → Helps set breakpoints, inspect variables, and step through code (Shift +
F9).
2. Logcat → Displays real-time logs, system messages, and error reports (View > Tool
Windows > Logcat).
3. Profiler → Monitors CPU, memory, and network usage to detect performance issues
(View > Tool Windows > Profiler).
4. Emulator → Simulates different Android devices for testing (Tools > Device
Manager).
5. Layout Inspector → Analyzes and debugs UI elements in real-time (View > Tool
Windows > Layout Inspector).

STEPS TO DEBUG AN ANDROID APPLICATION IN ANDROID STUDIO

1. Run in Debug Mode → Click Debug ▶ (Shift + F9) to start debugging your app.
2. Set Breakpoints → Click on the left margin of a code line to pause execution at that
point.
3. Inspect Variables → When execution pauses, check variable values in the Debugger
window.
4. Use Logcat → Open View > Tool Windows > Logcat to view real-time logs, errors,
and crash reports.
5. Step Through Code → Use Step Over (F8), Step Into (F7), and Step Out (Shift +
F8) for detailed execution flow analysis.
6. Analyze Performance → Use the Profiler (View > Tool Windows > Profiler) to
monitor CPU, memory, and network usage.
7. Fix and Retest → Identify issues, apply fixes, and rerun the app to verify solutions.

LAUNCHING YOUR FIRST ANDROID APPLICATION IN ANDROID STUDIO:


1. Install and Set Up Android Studio
• Download and install Android Studio from developer.android.com.
• Open Android Studio and complete the setup wizard.
2. Create a New Project
1. Open Android Studio and click "Start a new Android Studio project".
2. Select "Empty Activity" and click Next.
3. Configure the project:
o Name: MyFirstApp
o Package Name: com.example.myfirstapp
o Language: Java or Kotlin
o Minimum SDK: Choose a version (e.g., API 21: Lollipop).
4. Click Finish to create the project.
3. Understand the Project Structure
• Java/Kotlin folder: Contains the main code (MainActivity.java/MainActivity.kt).
• Res folder: Stores XML files for layouts, images, and resources.
• AndroidManifest.xml: Defines app permissions and configurations.
• Gradle files: Handles dependencies and project settings.
4. Modify the UI (Optional)
1. Open activity_main.xml in the res/layout folder and modify the code accordingly.
2. Save the file.
5. Run the Application on an Emulator
1. Click on AVD Manager (Android Virtual Device Manager).
2. Create a new virtual device (e.g., Pixel 4).
3. Select a system image (Android version).
4. Click Finish, then Run the emulator.
5. Click the Run button in Android Studio to launch the app.

PUBLISHING YOUR FIRST ANDROID APPLICATION:


1. Prepare Your App
Before publishing, ensure that your app is complete and ready for release. This includes:
Testing your app thoroughly on different devices.
Removing unnecessary logs and debugging tools.
Ensuring compliance with Google Play policies.

2. Create a Signed APK or App Bundle


Google Play requires apps to be signed before publishing.
Use Android Studio:
Open your project in Android Studio.
Go to Build > Generate Signed Bundle / APK.
Select Android App Bundle (AAB) (preferred) or APK.
Create a Keystore if you haven’t already (used for app signing).
Sign the build with your keystore and generate the file.
Keystore?
• A keystore is a file containing cryptographic keys used to sign your app.
• It’s essential for app updates—you must use the same keystore for future releases.

If the application has to be published on Google Play Store, we need to sign it before
uploading. Google Play requires either an Android App Bundle (AAB) (recommended) or an
APK.
App signing is a security mechanism where your app gets a digital signature using a keystore
file. This verifies that updates to your app come from the original developer and prevents
tampering.
3. Create a Google Play Developer Account
Go to the Google Play Console
Sign up as a developer (one-time fee of $25).
Complete the registration process.
4. Create a New App in Google Play Console
In the Play Console, click "Create app".
Enter app details like name, language, category (e.g., game, utility), and pricing (free/paid).
Agree to the Play Store policies.
5. Prepare Store Listing
Upload a high-resolution app icon (512x512 px).
Provide a detailed description of your app.
Add screenshots, feature graphics, and promo videos (optional but recommended).
Select the app category and tags.
6. Set Up App Content and Privacy Policy
Provide details about app content (target audience, age rating).
Submit a privacy policy URL if required.
7. Upload Your App (AAB or APK)
Go to the "Production" section and create a new release.
Upload your signed AAB or APK file.
Provide release notes (describe new features or bug fixes).
8. Review and Publish
Check for errors or warnings.
Click "Review release" and then "Start rollout to production".
Your app will go through Google’s review process (can take a few hours to a few days).
9. Post-Launch: Monitor and Update
Track app performance using Google Play Console analytics.
Read user reviews and feedback.
Release updates as needed.
Once approved, your app will be available for users to download on the Play Store
ANDROID ACTIVITY:
In Android Studio, an Activity is a crucial component of an Android app. It represents a single
screen with a user interface (UI). An app can have multiple activities, and users navigate
between them.
1. Declaring an Activity
Each activity must be declared in the AndroidManifest.xml file:
<activity android:name=".MyActivity" />
2. Creating an Activity
An activity is a subclass of android.app.Activity or, more commonly,
androidx.appcompat.app.AppCompatActivity.

Here’s an example:
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class MyActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // Linking to the UI
}
}
In Android, an Activity goes through a series of lifecycle states, managed by the system. The
lifecycle consists of the following key methods:
1. onCreate() → Called when the activity is first created. Used for initialization (e.g.,
setting up UI, data).
2. onStart() → Called when the activity becomes visible but not yet interactive.
3. onResume() → Called when the activity comes to the foreground and is ready for user
interaction.
4. onPause() → Called when the activity is partially visible (e.g., another activity appears
in front).
5. onStop() → Called when the activity is no longer visible. Used to release resources.
6. onDestroy() → Called before the activity is destroyed (e.g., app is closed or process is
killed).
7. onRestart() → Called when an activity is restarting after being stopped.

FEATURES OF AN ACTIVITY:
1. Manages the User Interface → An Activity represents a screen in an app, handling
UI elements and interactions.
2. Lifecycle Control → Activities go through lifecycle states (onCreate(), onStart(),
onResume(), etc.), managing app behavior.
3. Interactivity & User Input Handling → Listens to user actions like clicks,
gestures, and text input.
4. Navigation Between Screens → Uses Intents to switch between activities and pass
data.
5. Supports Fragments → Can host multiple Fragments, enabling modular and
dynamic UI components.
6. Handles Configuration Changes → Adapts to screen rotation, multi-window mode,
and other system changes.
7. Manages Background Processes → Can start background tasks like network calls,
services, or database operations.
8. Permission & Security Handling → Controls access to sensitive data like camera,
GPS, and storage.

APPLYING STYLES AND THEMES TO AN ACTIVITY:


In Android, styles and themes help define a consistent visual appearance across an application.
Styles are used to customize individual UI components, while themes apply a cohesive design
to an entire activity or app. Both are defined in XML files inside the res/values/ directory. The
styles.xml file contains reusable style definitions that can be applied to UI elements using the
style attribute. For example, a button can inherit a predefined style to maintain uniform colors
and typography.
Meanwhile, the themes.xml file defines a global theme that can be applied to an activity or the
entire application. Themes are set in the AndroidManifest.xml file using the android:theme
attribute within the <application> or <activity> tag. Material Design themes
(Theme.MaterialComponents) allow modern UI customization, including dark mode,
primary colors, typography, and shape styles. By effectively using styles and themes,
developers ensure a maintainable, visually consistent, and user-friendly interface across
different screen sizes and configurations.

HIDING THE TITLE OF AN ACTIVITY IN ANDROID STUDIO:


1. Hiding the Title via styles.xml: If you want to hide the title across the entire app or
specific activities, you can modify the theme in the res/values/styles.xml file. Then, apply
this theme to your activity in the AndroidManifest.xml:
<activity android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
...
</activity>
2.Hiding the Title Programmatically in Kotlin: If you want to hide the title only for
a specific activity, you can use the following code inside the onCreate() method of your
activity:

override fun onCreate(savedInstanceState: Bundle?) {


super.onCreate(savedInstanceState) // Hides the title
supportRequestWindowFeature(Window.FEATURE_NO_TITL E)
setContentView(R.layout.activity_main)
}

DISPLAYING DIALOG WINDOW USING AN ACTIVITY:


1. AlertDialog
2. DatePickerDialog
3. TimePickerDialog
4. CustomDialogs
5. BottomSheet Dialogs

PROGRESS BAR IN ANDROID:

A ProgressBar in Android is a UI component used to indicate ongoing tasks such as loading,


downloading, or processing. Android provides two types of progress bars:

1. Determinate ProgressBar → Used when the progress percentage is known (e.g., file
download).
2. Indeterminate ProgressBar → Used when the progress duration is unknown (e.g.,
loading data).
INTENT:

An Intent in Android is a messaging object used to request actions from other components
(such as Activities, Services, or Broadcast Receivers). It enables communication between
different parts of an application or between different apps. Intents can be used for
navigation, data sharing, and background operations.

There are two main types of intents:

1. Explicit Intent → Specifies the target component directly (e.g., opening a specific
activity).
2. Implicit Intent → Declares a general action, letting the system determine the
appropriate component (e.g., opening a web page, sending an email).

FEATURES OF INTENT:

1. Activity Navigation → Switch between activities within the same app.


2. Inter-App Communication → Share data between different applications (e.g., share
text via social media).
3. Service Activation → Start background services (e.g., playing music, fetching
location).
4. Broadcast Messaging → Send messages across system or app components (e.g.,
battery low notification).
5. Data Transfer → Pass data using putExtra() and retrieve it using getExtra().
6. Built-in Actions → Supports predefined actions like ACTION_VIEW,
ACTION_SEND, and ACTION_DIAL.
7. Result Handling → Use startActivityForResult() to receive data back from an
activity.

CREATING AN INTENT IN ANDROID


In Android, an Intent is used to navigate between activities or perform actions like opening a
web page, making a call, or sharing data. Below are examples of both EXPLICIT AND
IMPLICIT INTENTS.

1. Explicit Intent (Navigate to Another Activity)

Used when you want to start a specific activity within your app.

Example: Open SecondActivity from MainActivity

In MainActivity.kt:

val intent = Intent(this, SecondActivity::class.java)


intent.putExtra("message", "Hello from MainActivity!") // Passing data
startActivity(intent)

In SecondActivity.kt: (Retrieve data)

val message = intent.getStringExtra("message")


Toast.makeText(this, message, Toast.LENGTH_SHORT).show()

2. Implicit Intent (Open External Apps)

Used when you don't specify the target component, allowing Android to find the best app
to handle the action.

Example 1: Open a Web Page

val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"))


startActivity(intent)

NAVIGATING BETWEEN ACTIVITIES USING INTENTS IN ANDROID

In Android, you can navigate between activities using Intents. This allows seamless
transitions from one screen to another.

1. Using Explicit Intent (Switching Activities)

Create Two Activities (MainActivity and SecondActivity)

In MainActivity.kt (Starting Another Activity)

val intent = Intent(this, SecondActivity::class.java)


startActivity(intent) // Navigate to SecondActivity

In AndroidManifest.xml (Declare SecondActivity)

<activity android:name=".SecondActivity" />


2. Using Implicit Intent

An Implicit Intent is used when you want to perform an action without specifying a
particular component (activity).

Example: Open a Web Page

val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"))

startActivity(intent)

3. Navigating Back to Previous Activity

Android provides a Back Button, but you can also manually return to the previous activity.

In SecondActivity.kt:

finish() // Closes the activity and returns to the previous one


INTENT METHODS

INTENT ATTRIBUTES:
INTENT FILTERS

An Intent Filter in Android allows an app component (Activity, Service, or Broadcast


Receiver) to respond to implicit intents. It tells the Android system that the component can
handle a specific type of action, making the app discoverable for certain tasks.

Intent filters are defined inside the AndroidManifest.xml file using the <intent-filter> tag.

Components of intent filters:

Action
Category
Data

Action → Defines the action the component can handle

1. android.intent.action.VIEW

• Used to display or open content like a webpage, image, or document.

Example: Open a webpage in a browser

val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"))


startActivity(intent)

2. android.intent.action.SEND

• Used to share data (text, images, etc.) with other apps.

Example: Share text via social media apps

val intent = Intent(Intent.ACTION_SEND)


intent.type = "text/plain"
intent.putExtra(Intent.EXTRA_TEXT, "Check out this amazing app!")
startActivity(Intent.createChooser(intent, "Share via"))

3. android.intent.action.DIAL

• Opens the phone dialer with a number but does not make a call.

Example: Open dialer with a phone number

val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:1234567890"))


startActivity(intent)

4. android.intent.action.MAIN
• Used to define the entry point (MainActivity) of an app.

Example: Declare the main activity in AndroidManifest.xml

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

5. android.intent.action.EDIT

• Used to open an item (text, image, contact, etc.) for editing.

Example: Edit a contact

val intent = Intent(Intent.ACTION_EDIT)


intent.data = Uri.parse("content://contacts/people/1")
startActivity(intent)

6. android.intent.action.DELETE

• Used to delete an item like a file or contact.

Example: Delete a contact

val intent = Intent(Intent.ACTION_DELETE)


intent.data = Uri.parse("content://contacts/people/1")
startActivity(intent)

Category → Specifies additional information (e.g., android.intent.category.DEFAULT for


launchable activities).

1. android.intent.category.DEFAULT

• Required for implicit intents to be resolved.


• If an activity has an intent filter, it must include this category for implicit intents to
reach it.

Example: Allow an activity to receive implicit intents

<intent-filter>

<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
2. android.intent.category.BROWSABLE

• Allows an activity to be opened from a web browser or external links (e.g., clicking
a URL).
• Used when an activity can handle web-based intents (http or https).

Example: Open an activity from a webpage

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https" android:host="example.com"/>
</intent-filter>

3. android.intent.category.LAUNCHER

• Used to define the main entry point of the app (the activity shown in the app
drawer).
• This category makes an activity appear in the launcher.

Example: Set MainActivity as the launch activity

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

4. android.intent.category.HOME

• Used to create a custom home screen launcher (like Nova Launcher).


• When set, this activity will be listed when the user presses the home button and
chooses a default home screen.

Example: Define an activity as a home screen

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>

5. android.intent.category.APP_CONTACTS

• Used to filter activities related to contacts (e.g., opening the contacts list).
• Can be used in conjunction with ACTION_VIEW or ACTION_PICK.
Example: Open the contacts app

val intent = Intent(Intent.ACTION_VIEW)


intent.addCategory(Intent.CATEGORY_APP_CONTACTS)
intent.data = Uri.parse("content://contacts/people/")
startActivity(intent)

6. android.intent.category.APP_CALENDAR

• Used to filter activities related to the calendar, such as viewing or adding calendar
events.

Example: Open the calendar app

val intent = Intent(Intent.ACTION_MAIN)


intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
startActivity(intent)

Data → Specifies the type of data (e.g., URL, MIME type, phone number).

1. URI Scheme

• A Uniform Resource Identifier (URI) Scheme is a way to identify and access


resources like web links, phone numbers, or files. Android apps use URI schemes to
define how to open specific types of content.
• Common URI Schemes in Android

URI Scheme Purpose Example


http:// or https:// Open web pages https://www.google.com
tel: Open phone dialer tel:1234567890
sms: Open messaging app sms:1234567890
mailto: Open email client mailto:example@gmail.com
geo: Open map locations geo:37.7749,-122.4194
content:// Access shared content (contacts, media, etc.) content://contacts/people/1
file:// Access local storage files file:///sdcard/sample.txt

2. MIME Type

A Multipurpose Internet Mail Extensions (MIME) Type defines the format of the data
being handled, such as images, videos, audio files, or documents.

Common MIME Types in Android


MIME Type Purpose Example
Open text-based
text/plain Sharing text data
content
Handle any image Viewing or selecting an
image/*
format image
Handle any video
video/* Playing a video file
format
Handle any audio
audio/* Playing an audio file
format
application/pdf Open PDF files Viewing a PDF document
application/msword Open Word files Viewing a .doc file

PASSING DATA BETWEEN ACTIVITIES


Use putExtra() to send data and getStringExtra() to receive it.

Send Data from MainActivity


val intent = Intent(this, SecondActivity::class.java)
intent.putExtra("message", "Hello from MainActivity!")
startActivity(intent)

Receive Data in SecondActivity


val message = intent.getStringExtra("message")

FRAGMENTS:
Fragment is a piece of an activity that enables a more modular activity design. A fragment
encapsulates functionality so that it is easier to reuse within activities and layouts.
LIFECYCLE OF A FRAGMENT:

A fragment goes through the following lifecycle states:

1. onAttach() → Fragment is attached to the activity.


2. onCreate() → Initializes the fragment (but UI is not yet created).
3. onCreateView() → Inflates the fragment’s UI.
4. onViewCreated() → Called after onCreateView(), initializes UI components.
5. onStart() → Fragment is now visible.
6. onResume() → Fragment is now active and interactive.
7. onPause() → Fragment is partially visible (e.g., another activity is on top).
8. onStop() → Fragment is no longer visible.
9. onDestroyView() → View is destroyed, but the fragment still exists.
10. onDestroy() → Final cleanup of fragment resources.
11. onDetach() → Fragment is detached from the activity.

ADDING FRAGMENTS DYNAMICALLY

1. Create a Fragment Class

Define a fragment by extending the Fragment class.

2. Create a Fragment Layout

Define the UI for the fragment.

3. Add a Container for the Fragment

Modify your activity layout to include a FrameLayout as a placeholder for fragments.

4. Add the Fragment Dynamically in the Activity

Use FragmentManager and FragmentTransaction to add the fragment dynamically when the
button is clicked.

UNDERSTANDING BACK STACK IN ANDROID:

What is the Back Stack?

The Back Stack in Android is a stack data structure used to manage the navigation of
activities and fragments. It follows the Last In, First Out (LIFO) principle, meaning the
most recently added element is removed first when the back button is pressed.

• When you start a new Activity, the previous one is pushed onto the stack.
• Pressing the Back Button removes the topmost activity and returns to the previous
one.
• The same principle applies to Fragments within an Activity.

IMPLEMENTING A NEW ACTIVITY USING EXPLICIT INTENT, IMPLICIT


INTENT, AND CONTENT PROVIDER

In Android, an Activity can be started using an Explicit Intent or an Implicit Intent.


Additionally, Content Providers help access data from other applications. Below are the
steps to implement these concepts.

1. Creating a New Activity


First, create a new activity that will be opened using different types of intents.

Steps to Create an Activity:

1. Right-click on the package name in Android Studio → New → Activity → Empty


Activity.
2. Name it SecondActivity and click Finish.

SecondActivity.kt

class SecondActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_second)

val textView = findViewById<TextView>(R.id.txtMessage)


val message = intent.getStringExtra("EXTRA_MESSAGE")
textView.text = message
}
}

activity_second.xml (UI Layout)

<TextView
android:id="@+id/txtMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello from Second Activity!"
android:textSize="20sp"
android:layout_gravity="center"/>

2. Opening Activity using Explicit Intent

An Explicit Intent is used when you know the target activity you want to open.

Example: Open SecondActivity from MainActivity

val intent = Intent(this, SecondActivity::class.java)


intent.putExtra("EXTRA_MESSAGE", "Hello from MainActivity")
startActivity(intent)

✔ Use Case: Navigating between activities within the same app.

3. Opening Activity using Implicit Intent


An Implicit Intent is used when you want to perform an action without specifying a
particular component (activity).

Example: Open a Web Page

val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"))


startActivity(intent)

Example: Open Dialer with a Phone Number

val intent = Intent(Intent.ACTION_DIAL)


intent.data = Uri.parse("tel:1234567890")
startActivity(intent)

Example: Share Text using Other Apps

val intent = Intent(Intent.ACTION_SEND)


intent.type = "text/plain"
intent.putExtra(Intent.EXTRA_TEXT, "Hello! Check this out.")
startActivity(Intent.createChooser(intent, "Share via"))

✔ Use Case: Opens system apps like browser, dialer, or allows sharing data.

4. Accessing Data using Content Provider

A Content Provider allows apps to share and access structured data, like contacts, media,
etc.

Example: Fetch Contacts from the Device

val uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI


val cursor = contentResolver.query(uri, null, null, null, null)

if (cursor != null && cursor.moveToFirst()) {


val columnIndex =
cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)
val phoneNumber = cursor.getString(columnIndex)
cursor.close()
Toast.makeText(this, "Contact: $phoneNumber", Toast.LENGTH_SHORT).show()
}

You might also like