0% found this document useful (0 votes)
25 views40 pages

Karthik PPT

The document is an internship report on Google Android Developer basics, detailing an 8-unit course on Android development using Jetpack Compose. It covers topics such as app UI building, state management, navigation, and creating custom components, emphasizing the advantages of using Jetpack Compose over traditional XML-based development. Additionally, it discusses the setup of the development environment, the importance of data binding, and UI testing in Jetpack Compose.

Uploaded by

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

Karthik PPT

The document is an internship report on Google Android Developer basics, detailing an 8-unit course on Android development using Jetpack Compose. It covers topics such as app UI building, state management, navigation, and creating custom components, emphasizing the advantages of using Jetpack Compose over traditional XML-based development. Additionally, it discusses the setup of the development environment, the importance of data binding, and UI testing in Jetpack Compose.

Uploaded by

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

Autonomous

(Approved by AICTE, New Delhi, Affiliated to JNTUA, Ananthapuram & Accredited by NBA)
AYYALURMETTA(V), NANDYAL(Dist.)-518505, A.P.

AN INTERNSHIP REPORT ON

GOOGLE ANDROID DEVLOPER

By

P.N.KARTHIK 21AM1A3147
Under the Estimated Guidance of

Mr.M. RAMACHANDRUDU M. Tech


Assistant professor
Dept. of CSE - AI
Google Android Developer Basics with Compose Contents

Android Basics with Compose is divided into 8 units, each covering a different aspect of Compose and Android development. Some
of the topics covered are:

Unit - 1 : Your First Android App


 Introduction to Kotlin
 Setup Android Studio Unit - 5: Connect to the Internet
 Build a basic layout  Get data from the Internet
 Load and display images from the Internet
Unit - 2 : Building app UI
 Kotlin Fundamentals Unit - 6: Data Persistence
 Add a button to an app  Introduction to SQL

 Interacting with UI and state  Use Room for data persistence


 Store and access data using keys with DataStore
Unit - 3 : Display lists and use Material Design
 More Kotlin fundamentals Unit - 7: Work Manager
 Build a scorable list  Schedule tasks with WorkManager

 Build beautiful apps Unit - 8: Views and Compose


 Android Views and Compose in Views
Unit - 4 : Navigation and App Architecture
 Architecture Components  Views in Compose

 Navigation in Jetpack Compose


 Adapt for different screen sizes
Eduskills Google Developers: Android Basics with Compose

Edu skills Google Developers: Android Basics with Compose offers an


essential introduction to modern Android UI development through
Jetpack Compose. This course provides foundational knowledge in
creating intuitive, responsive user interfaces with Compose’s declarative
approach. Participants will explore core concepts such as composables,
state management, and layout building, along with practical skills in
theming and interactive elements. Ideal for beginners and seasoned
developers alike, the course combines interactive lectures, hands-on
labs, and real-world examples to ensure a comprehensive understanding
of Compose. By the end, learners will be adept at developing dynamic,
visually appealing Android applications using cutting-edge techniques.
What is Android?
Android is a mobile operating system developed by Google, based on the
Linux kernel. It is designed for touchscreen devices such as smartphones
and tablets, providing a rich, customizable user experience with access to a
wide range of apps and services.
Popularity: Android is the most widely used mobile OS globally, powering
over 70% of smartphones and tablets. Its open-source nature and extensive
app ecosystem contribute to its widespread adoption.
Use Cases: Android is used in smartphones, tablets, smartwatches, TVs, and
even automotive systems, making it versatile for various applications.
Role in Mobile App Market: Android dominates the mobile app market,
with millions of apps available on the Google Play Store. Its large user base
and open ecosystem make it a key platform for developers and businesses.
Introduction to Jetpack Compose
Jetpack Compose is a modern UI toolkit for Android that uses a declarative approach to
simplify UI development. It allows developers to build user interfaces with Kotlin code
instead of XML, describing what the UI should look like in response to data changes.
Declarative Nature: Compose's declarative nature means developers define UI
components as composable functions, which automatically update when the underlying
data changes. This contrasts with the imperative style of XML, which requires manual
updates and complex view management.
Comparison to XML-based UI Development:
 XML-based UI: Uses separate XML files for layouts and imperative code for
managing views and updates. This often involves verbose code and manual view
hierarchy management.
 Jetpack Compose: Integrates UI design directly into Kotlin code with composable
functions, reducing boilerplate and simplifying view updates through a declarative
syntax.
 Advantages of Using Compose:
 Faster Development: Real-time previews and a concise syntax enable quicker UI
prototyping and changes.
 Declarative Syntax: Simplifies code readability and writing by
allowing developers to describe the UI's appearance and
behavior in a straightforward, declarative manner, reducing
boilerplate code and complexity.
 Live Previews: Provides instant feedback through real-time UI
previews in the IDE, enabling developers to quickly see and
adjust changes without rebuilding the app.
 Interoperability: Seamlessly integrates with existing Android
code and XML-based UI elements, allowing for gradual
migration and use alongside traditional components.
 Performance Optimizations: Includes built-in optimizations
for efficient UI rendering and re-composition, enhancing
performance and responsiveness compared to traditional view
systems.
Setting Up Your Development Environment for Jetpack Compose
1.Install Android Studio:
 Download: Get the latest version from the Android Studio website.
 Install: Follow the installation instructions for your operating system.
2.Configure for Compose Development:
 Update Gradle Plugin: Ensure you have the latest Android Gradle
Plugin version in your project’s build.gradle file.
 Add Compose Dependencies: Include Jetpack Compose dependencies
in your app module’s build.gradle file and enable Compose by setting
buildFeatures.compose to true.
 Sync Project: Sync Gradle to apply the changes.
3.SDK and Plugin Requirements:
 Android SDK: Install SDK version 21 or higher via the SDK Manager.
 Kotlin Version: Use Kotlin 1.5 or later.
 Compose Plugin: Ensure Compose-related plugins are enabled and up-
to-date.
Creating a New Compose Project
1.Create a New Project:
 Open Android Studio: Select "New Project."
 Choose Template: Select "Empty Compose Activity" and click
"Next."
 Configure Project: Enter project details, choose Kotlin, set the
minimum SDK to 21 or higher, and click "Finish."
2.Project Structure and Key Files:
 AndroidManifest.xml: Declares app components and
permissions.
 build.gradle (Module: app): Includes Compose dependencies
and configurations.
 Theme.kt: Defines app themes, including colors and typography.
 MainActivity.kt: Contains the main activity with @Composable
functions and setContent for the Compose UI.
 Preview.kt: Contains @Preview functions to visualize UI
components in Android Studio.
Text Component
The Text component is used to display textual content within your UI. It
provides various properties for customizing the appearance and behavior of the
text.
Properties:
 text: The actual text to be displayed.
 color: The color of the text.
 fontSize: The size of the text in sp (scale-independent pixels).
 fontStyle: The font style, such as normal, italic, or bold.
 fontFamily: The font family to use.
 textAlign: The alignment of the text within the component.
 maxLines: The maximum number of lines allowed for the text.
 modifier: A modifier to apply additional styling or behavior to the Text
component.
Layouts in Jetpack Compose: Column, Row, and Box

Column
 Definition: Arranges child elements vertically, one below the
other.
 Modifier: Modifier. Column()
Row
 Definition: Arranges child elements horizontally, side by side.
 Modifier: Modifier.row()
Box
 Definition: Provides a flexible layout container that allows for
more complex positioning and alignment of child elements.
 Modifier: Modifier.fillMaxSize() or Modifier.size()

Additional Considerations:
 Modifiers: You can use modifiers to customize the appearance and
behavior of layouts and their child elements. For example, you can
use Modifier.padding() to add spacing around elements or
Modifier.weight() to distribute space among child elements.
 Alignment: You can use alignment modifiers like Modifier.align()
to position elements within a layout.
 Constraints: You can use constraints to define relationships
between elements and create more complex layouts.
State Management with mutableStateOf in Jetpack Compose
State Management is a fundamental concept in Jetpack Compose. It refers to the
process of storing and updating data that affects the UI. When the state changes,
the UI is automatically recomposed to reflect the new data.
mutableStateOf is a function provided by Compose that allows you to create and
manage state variables. It returns a Mutable State object, which holds the current
value of the state variable.
Understanding mutableStateOf
mutableStateOf is a fundamental component in Jetpack Compose for managing
state. It allows you to create mutable state variables that are automatically
observable by Compose. When a state variable changes, Compose triggers
recompositions, ensuring the UI is updated to reflect the new state. This
declarative approach simplifies managing and updating UI elements based on
state changes.
Creating and Managing State Variables:
1.Import the necessary package:
Kotlin
import androidx.compose.runtime.mutableStateOf
2.Create a state variable:
Kotlin
val counter = mutableStateOf(0)
Key Points:
 Immutability: The mutableStateOf function returns a Mutable State
object, which is immutable. To update the value, you must modify the
value of the Mutable State object directly.
 Recompositions: When a state variable changes, Compose triggers a
recomposition of the UI components that depend on that state.
 Efficiency: Compose's reactivity system is designed to be efficient,
minimizing unnecessary recompositions.
Theming and Styling in Jetpack Compose
Theming in Jetpack Compose allows you to create a consistent
visual appearance across your entire app. Styling involves
customizing individual UI elements to match your desired design.
Creating Custom Themes
 Create a theme file: Create a new resource file under res/values
named themes.xml.
 Define a base theme: Create a base theme that inherits from a
system theme (e.g., Theme.Material3.Light or
Theme.Material3.Dark).
 Customize theme properties: Customize properties like
primaryColor, secondaryColor, backgroundColor, and
fontFamily to match your desired theme.
Using Material Design Components and Themes
Compose provides a rich set of Material Design components that
follow Material Design guidelines. These components automatically
inherit the theme properties defined in your theme file, ensuring a
consistent look and feel.
Modifier API in Jetpack Compose

Modifiers are a powerful mechanism in Jetpack Compose that allow you


to customize the appearance and behavior of UI components. They are
applied to components using the modifier property.
Common Modifiers
 padding: Adds padding around a component.
 size: Sets the width and height of a component.
 background: Sets the background color or drawable of a component.
 clickable: Makes a component clickable and defines the action to be
performed when clicked.
 fillMaxSize: Fills the available space within a parent layout.
 align: Positions a component within a parent layout.
 clickable: Makes a component clickable and defines the action to be
performed when clicked.
 border: Adds a border around a component.
 clip: Clips the content of a component to a specific shape.
 alpha: Sets the opacity of a component.
 scale: Scales a component to a specific size.
 rotate: Rotates a component by a specified angle.
 padding: Adds padding around the button.
 size: Sets the width and height of the button.
 background: Sets the background color of the button to
blue.
 clickable: Makes the button clickable and defines an action
to be performed when clicked.
Lazy Column and LazyRow: Efficient Rendering of Large Lists
LazyColumn and LazyRow are specialized Compose layouts designed to
efficiently render large lists of items. Unlike traditional lists, these layouts only
create and render the items that are currently visible on the screen, reducing
memory usage and improving performance.
Benefits of LazyColumn and LazyRow
 Improved performance: By only rendering visible items, these layouts can
significantly improve the performance of your app, especially when dealing
with large datasets.
 Reduced memory usage: Since only a subset of items is rendered at a time,
memory usage is reduced, leading to better app responsiveness.
 Infinite scrolling: LazyColumn and LazyRow can be used to implement
infinite scrolling, allowing users to load more data as they scroll.
Key points to remember:
 Item keys: To ensure efficient updates, provide unique keys for each item
using the key parameter of the items function.
Creating Custom Compose Components
Custom components in Jetpack Compose allow you to encapsulate reusable UI elements, making your code
more modular, organized, and maintainable.
Benefits of Using Custom Components
 Reusability: Custom components can be reused throughout your app, reducing code duplication and
improving maintainability.
 Modularity: Encapsulating UI elements into components promotes a modular architecture, making your
code easier to understand and manage.
 Flexibility: Custom components can be made more flexible by accepting parameters and modifiers,
allowing you to customize their behavior and appearance.
Creating a Custom Component
 1. Define a Composable function: Create a Composable function that represents your custom component.
Give it a descriptive name.
 2. Define parameters and modifiers: If your component requires any parameters or modifiers, add them
as arguments to the Composable function.
 3. Implement the UI: Inside the Composable function, define the UI elements that make up your
component. Use Compose's layout system (Column, Row, Box) to arrange the elements.
 4. Return the UI: Return the root Composable that represents your component.
Breakdown of the code:
1.Greeting Composable: This function defines the greeting card component.
2.Card: A Material Design component that provides a raised card effect.
3.Column: Arranges the content vertically within the card.
4.Text: Displays the greeting message and a welcome message.
How it works:
 The Greeting function takes a name parameter, which will be used in the greeting message.
 The Card component creates a raised card effect around the content.
 The Column arranges the text elements vertically within the card.
 The Text components display the greeting message and the welcome message.
Navigation Compose: A Powerful Tool for Managing Navigation
Navigation Compose is a Jetpack Compose library that simplifies the process of managing
navigation between different screens in your Android app. It provides a declarative API for
defining navigation graphs and handling navigation actions.
Benefits of Using Navigation Compose
 Centralized navigation: Navigation Compose allows you to define all your app's
navigation routes in a single location, making it easier to manage and understand.
 Declarative API: The declarative syntax of Navigation Compose makes it easy to define
navigation graphs and transitions.
 Backstack management: Navigation Compose automatically manages the backstack,
ensuring that users can navigate back to previous screens.
 Deep linking: Navigation Compose supports deep linking, allowing users to directly
navigate to specific screens within your app.
 Animations: You can easily define custom animations for screen transitions using

Navigation Compose.
Dialogs and Bottom Sheets in Jetpack Compose
Dialogs and bottom sheets are modal UI elements that temporarily overlay the main content of your app to present
important information or prompt the user for input.
Dialogs:
Dialogs are used to display important information or require user input. They are typically used for actions that
require immediate attention or confirmation.
Bottom Sheets:
Bottom sheets are used to present content that is related to the current screen but doesn't require immediate
attention. They are often used for actions like selecting options, filtering content, or displaying additional
information.
Differences Between Dialogs and Bottom Sheets:
 Appearance: Dialogs are typically full-screen overlays, while bottom sheets slide up from the bottom of the
screen.
 Usage: Dialogs are used for important information or actions that require immediate attention, while bottom
sheets are used for related content that doesn't require immediate attention.
 Dismissal: Dialogs can be dismissed by the user or automatically after a certain timeout, while bottom sheets
can be dismissed by swiping down or clicking outside the sheet.
Toasts and Snackbars in Jetpack Compose
Toasts and snackbars are both used to provide short, non-blocking messages
to the user. However, they have some key differences:
 Position: Toasts typically appear at the bottom of the screen, while
snackbars can appear at the top or bottom.
 Action: Snackbars can optionally include an action button, while toasts do
not.
 Duration: Toasts have a fixed duration (usually short or long), while
snackbars can be dismissed by the user or automatically after a specified
duration.
Data binding in Jetpack Compose allows you to dynamically update UI elements based on changes
in underlying data. This eliminates the need for manual updates and makes your code more reactive
and easier to maintain.
Benefits of Data Binding
 Improved code readability: Data binding makes your code more declarative and easier to
understand, as the UI is directly linked to the data.
 Reduced boilerplate code: Data binding can reduce the amount of boilerplate code you need to
write to update the UI.
 Enhanced performance: Compose's reactivity system ensures that only the necessary parts of
the UI are updated when data changes, improving performance.
UI Testing in Jetpack Compose
UI testing is essential for ensuring the quality and reliability of your Android
applications. It involves testing the behavior of your app's user interface to verify that
it functions as expected and provides a good user experience.
Importance of UI Testing
 Ensures correctness: UI tests can help identify and fix bugs or unexpected
behavior in your app's UI.
 Improves user experience: By testing your app's UI, you can ensure that it is easy
to use and provides a positive experience for users.
 Verifies functionality: UI tests can verify that your app's features work as
intended.
 Regression testing: UI tests can help prevent regressions by ensuring that changes
to your code don't break existing functionality.
Performance Optimization in Jetpack Compose
Performance optimization is crucial for creating smooth and responsive Android apps. Here are some
techniques to optimize your Jetpack Compose applications:
Identify Performance Bottlenecks
 Use the Profiler: The Android Profiler provides tools to identify performance issues, including CPU usage,
memory allocation, and rendering performance.
 Monitor recompositions: Use the RecomposeTimer to measure the frequency and duration of
recompositions.
 Check for excessive state updates: Avoid unnecessary state updates that trigger frequent recompositions.
 Optimize Compose Code
 Minimize recompositions:
 Use remember to cache values that don't change.
 Use key to prevent unnecessary recompositions when items in a list are reordered.
 Use derivedStateOf to calculate derived values efficiently.
 Avoid complex calculations in Composable functions: Move expensive calculations to separate functions
or use remember to cache the results.
 Use hardware acceleration: Enable hardware acceleration in your build settings for smooth animations
and transitions.
 Optimize images: Use appropriate image formats and sizes to reduce memory usage and loading times.
State Management with ViewModel and LiveData in Jetpack Compose
ViewModel and LiveData are powerful tools for managing state in Android applications, including
those built with Jetpack Compose. They provide a robust and scalable solution for handling data
and updating the UI.
View Model:
 Centralized state management: A ViewModel is a class that holds and manages UI-related
data. It's designed to outlive the lifecycle of individual activities and fragments, ensuring that
data persists even when the UI is recreated.
 Data binding: You can bind UI elements to ViewModel properties using data binding or by
directly observing the ViewModel's properties in Compose.
 Lifecycle awareness: ViewModels are lifecycle-aware, meaning they can automatically handle
lifecycle events like onStart, onPause, and onDestroy, ensuring that data is preserved correctly.
Live Data
Observable data holder: Live Data is a lifecycle-aware observable data holder class. It
automatically updates its observers (UI components) when its value changes.
Centralized data management: Like View Model, Live Data can be used to manage state
and data flow within your app.
Transformations: Live Data supports transformations, allowing you to map or filter the
data before it's observed by UI components.
Benefits of Using View Model and Live Data
Improved code organization: View Models and Live Data help separate concerns and
make your code more maintainable.
Centralized state management: Data is managed in a single location, making it easier to
control and update.
Lifecycle awareness: View Models and Live Data automatically handle lifecycle events,
ensuring that data is preserved correctly.
Data binding: Data binding simplifies the process of updating UI elements based on data
Architecture Components: Room and Coroutines
Room and Coroutines are powerful tools provided by the Android Jetpack library that can greatly simplify database
operations and asynchronous programming in your Compose applications.
Room
•Database abstraction layer: Room provides a database abstraction layer that simplifies database interactions,
making it easier to work with SQLite databases in your Android apps.
•Entity classes: You define entities to represent your data model.
•DAO interfaces: You define Data Access Objects (DAOs) to specify database queries and operations.
•Automatic generation: Room generates necessary code for database access, including SQL statements and entity
classes.
Coroutines
•Asynchronous programming: Coroutines provide a lightweight way to write asynchronous code in Kotlin. They are
well-suited for tasks that might block the main thread, such as database operations or network requests.
•Suspending functions: Coroutines use suspending functions to represent asynchronous operations.
•Flow: Coroutines also introduce the Flow type, which can be used to represent streams of data.
Optimizing Performance in Jetpack Compose Apps

Identifying Performance Bottlenecks


•Use the Android Profiler: The Profiler can help you identify performance issues related to CPU usage, memory
allocation, and rendering performance.
•Monitor recompositions: Use the RecomposeTimer to measure the frequency and duration of recompositions.
•Check for excessive state updates: Avoid unnecessary state updates that trigger frequent recompositions.
Techniques for Improving Performance
•Minimize recompositions:
•Use remember to cache values that don't change.
•Use key to prevent unnecessary recompositions when items in a list are reordered.
•Use derivedStateOf to calculate derived values efficiently.
•Avoid complex calculations in Composable functions: Move expensive calculations to separate functions or
use remember to cache the results.
•Optimize layouts: Use efficient layouts like LazyColumn and LazyRow for large lists. Avoid nested layouts and
unnecessary modifiers.
•Use hardware acceleration: Enable hardware acceleration in your build settings for smooth animations and
transitions.
Integrating APIs and Data in Jetpack Compose

Integrating APIs and data is a crucial aspect of building dynamic and interactive Android
apps. Jetpack Compose provides powerful tools and mechanisms to handle data fetching,
caching, and updating the UI based on the data.
Fetching Data from APIs
•Use coroutines and suspend functions: Coroutines are well-suited for asynchronous
operations like network requests. Use suspending functions to fetch data from APIs.
•Handle errors and loading states: Implement error handling and loading states to provide
a better user experience.
•Consider using a network library: Libraries like Retrofit can simplify API interactions
and handle common tasks like serialization and deserialization.
Navigation Patterns in Jetpack Compose
Navigation patterns in Jetpack Compose provide a structured way to manage the flow and structure of your app. .
Common Navigation Patterns
1.Bottom Navigation:
•Use case: Suitable for apps with a few main screens that can be accessed from the bottom navigation bar.
•Implementation: Use the BottomNavigation component to create a bottom navigation bar with multiple destinations.
2.Drawer Navigation:
•Use case: Ideal for apps with a large number of screens that can be organized into categories or sections.
•Implementation: Use the DrawerLayout component to create a drawer navigation menu.
3.Tabs:
•Use case: Suitable for apps with multiple related screens that can be easily switched between.
•Implementation: Use the TabRow and Tab components to create a tab bar.
4.Hierarchical Navigation:
•Use case: Appropriate for apps with a hierarchical structure, such as a master-detail view.
•Implementation: Use nested navigation graphs to represent the hierarchy.
5.Modal Navigation:
•Use case: For presenting temporary screens or dialogs that require user interaction before returning to the previous screen.
•Implementation: Use the Dialog or BottomSheet components to create modal screens.
Advanced Animations in Jetpack Compose
Jetpack Compose offers a powerful and flexible animation system that allows you to create complex and
visually appealing animations in your Android apps. Here are some advanced animation techniques and
concepts:
Keyframes and Transitions
•Keyframes: Define specific points in an animation sequence, allowing you to control the timing, values,
and easing functions for each point.
•Transitions: Create smooth transitions between different UI states using keyframes and easing
functions.
Tips for Effective Animations
•Use keyframes for precise control.
•Experiment with different easing functions.
•Consider performance implications of complex animations.
•Test your animations on different devices and screen sizes.
Introduction to SQL: A Primer for Jetpack Compose
SQL (Structured Query Language) is a standard programming language used to interact with
relational databases. When developing Android applications with Jetpack Compose, understanding SQL
is essential for efficiently managing and persisting data.
Key Concepts
 Database: A collection of related data organized into tables.
 Table: A structure composed of rows and columns, where each row represents a record and each
column represents a field.
 Row: A single record within a table.
 Column: A field within a table that stores a specific type of data (e.g., text, numbers, dates).
 Primary Key: A unique identifier for each row within a table.
 Foreign Key: A column that references the primary key of another table, establishing a relationship
between the two.
Common SQL Operations
 SELECT: Retrieves data from one or more tables.
 INSERT: Adds new rows to a table.
 UPDATE: Modifies existing data within a table.
 DELETE: Removes rows from a table.
Using Room for Data Persistence
Room is part of Jetpack and provides an abstraction layer over SQLite to allow for more robust database
access while harnessing the full power of SQLite.
Provides a robust way to interact with SQLite databases in Android. Define entities, DAOs, and databases,
then integrate them with Jetpack Compose
Steps to Use Room in Jetpack Compose:
Define Entity
An entity represents a table within the database. Define a data class and annotate it with @Entity. Each entity
needs a primary key.
Create DAO (Data Access Object)
DAO interfaces define methods for interacting with the database. Annotate methods with SQL queries to
perform CRUD operations (Create, Read, Update, Delete).
Create Database
Define a Room database class that extends Room Database. This class holds the database and provides a way
to access DAOs.

Use ViewModel for Data Management


Use ViewModel to manage UI-related data in a lifecycle-conscious way. This ensures that data survives
configuration changes such as screen rotations.
Store and access data using keys with DataStore
Storing and accessing data using DataStore in Android provides a modern, efficient way to
manage simple key-value pairs or typed objects. DataStore is a replacement for SharedPreferences
and is designed to be more robust, scalable, and easier to use with asynchronous operations.
DataStore with Jetpack Compose for storing and accessing data using keys:
Setting Up DataStore
DataStore supports two types of storage:
 Preferences DataStore: For storing key-value pairs.
 Proto DataStore: For storing typed data with ProtoBuf.

 DataStore: Provides a modern, asynchronous alternative to SharedPreferences for storing key-


value pairs.
 Preferences DataStore: Ideal for simple key-value storage. Use DataStore<Preferences> for
this purpose.
 Asynchronous Operations: DataStore supports asynchronous read and write operations,
making it suitable for modern Android applications.
Schedule tasks with WorkManager

Scheduling tasks with Work Manager in Android is a powerful way to handle background
work that needs to be guaranteed, such as periodic updates, file uploads, or database
cleanups. WorkManager is part of the Android Jetpack suite and offers a consistent API for
managing background tasks that need to be run reliably.
Create a Worker
 A Worker class is where you implement the task that you want to perform in the
background. This class must extend Worker and override the doWork method.
Create Work Requests
Work Manager supports different types of work requests:
 One-Time Work Request
A OneTimeWorkRequest is used for tasks that need to be executed only once.
 Periodic Work Request
A PeriodicWorkRequest is used for tasks that need to be repeated at regular intervals
Define Constraints
 Constraints ensure that your work runs only under specific conditions, such as when the device is

connected to the internet or charging .

Chain Work Requests


 You can chain multiple work requests to run sequentially or concurrently.

Observe Work Status


 You can monitor the status of your work request using Live Data .

Handling Work Failure and Retry


 Work Manager can automatically retry failed work. You can configure retry behavior using
BackoffCriteria.

Integrate with Jetpack Compose


 To integrate Work Manager with Jetpack Compose, you can use composables to trigger and observe
background tasks.
Example: Triggering Work from a Composable
Android Views and Compose in Views
In Android development, Jetpack Compose provides a modern, declarative way to build UIs. However,
Android applications often need to integrate Jetpack Compose with traditional Android Views for
various reasons, such as maintaining compatibility with existing codebases or leveraging specific
functionality not yet available in Compose.
Using Android Views in Compose
Jetpack Compose allows you to use traditional Android Views within Compose UI using the Android
View composable. This composable enables you to embed traditional Views into your Compose-based
UI, giving you flexibility and compatibility.
Handling State and Events
When integrating Android Views with Compose, you may need to handle state changes or events from
the Views. You can achieve this by using Android View's update function to configure the View based on
Compose state.
Views in Compose
Jetpack Compose revolutionizes Android UI development by introducing a declarative approach,
simplifying the process of building and managing user interfaces. Unlike traditional XML-based layouts,
Compose allows developers to describe UIs using Kotlin code, making UI creation more intuitive and
flexible.
Views in Compose
In Jetpack Compose, the concept of "Views" is replaced by "Composables," which are functions that
define a part of the UI. These composables allow you to construct UI elements declaratively
Composable Functions
Composable functions are the building blocks of UI in Compose. They describe what the UI should look
like based on the current state and react to state changes. For instance, a composable function can
encapsulate UI elements such as text, buttons, and layouts, and can be easily composed together to create
complex interfaces.
.
conclusion
This internship has solidified my interest in mobile development, and I
am confident that the skills and knowledge I acquired will significantly
contribute to my career in software development. It has also taught me
the importance of adaptability, continuous learning, and teamwork in a
fast-paced tech environment.

You might also like