SlideShare a Scribd company logo
Extended
Kuala Lumpur
What’s new in Android
JetPack
Hassan Abid, GDE Android
Twitter, Instagram, Github : @hassanabidpk
Contents
- Alpha
- CameraX
- LiveData and LifeCycle w/ coroutines
- Benchmark
- Security
- ViewModel with SavedState
- ViewPager2
- Beta
- ConstraintLayout 2.0
- BioMetric Prompts
- Stable
- JetPack Compose
- WorkManager
- Navigation
Extended
Kuala Lumpur
CameraX
CameraX (alpha)
- Backward compatible with L+ devices
- Consistent behavior across devices
- Easy to use APIs
- Based on Camera2 Apis but hides Hardware layer
CameraX - issues tackled
- Front/back camera switch crashes
- Optimized camera closures
- Orientation Incorrect
- Flash not firing
CameraX API (alpha)
- Preview
- Image Analysis
- Image Capture
Extended
Kuala Lumpur
Deep dive into CameraX
Preview API
val previewConfig = PreviewConfig.Builder().build()
Preview API
val previewConfig = PreviewConfig.Builder().build()
val preview = Preview(previewConfig)
Preview API
val previewConfig = PreviewConfig.Builder().build()
val preview = Preview(previewConfig)
val textureView: TextureView = findViewById(R.id.textureView)
Preview API
val previewConfig = PreviewConfig.Builder().build()
val preview = Preview(previewConfig)
val textureView: TextureView = findViewById(R.id.textureView)
// The output data-handling is configured in a listener.
preview.setOnPreviewOutputUpdateListener { previewOutput ->
textureView.surfaceTexture = previewOutput.surfaceTexture
}
Preview API
val previewConfig = PreviewConfig.Builder().build()
val preview = Preview(previewConfig)
val textureView: TextureView = findViewById(R.id.textureView)
// The output data-handling is configured in a listener.
preview.setOnPreviewOutputUpdateListener { previewOutput ->
textureView.surfaceTexture = previewOutput.surfaceTexture
}
// The use case is bound to an Android Lifecycle with the following code.
CameraX.bindToLifecycle(this as LifecycleOwner, preview)
Extended
Kuala Lumpur
CameraX Lifecycles
CameraX Lifecycles
- CameraX observes a lifecycle to determine camera states
- When to open and close session
Image Analysis API
val imageAnalysisConfig = ImageAnalysisConfig.Builder()
.setTargetResolution(Size(1280, 720))
.build()
Image Analysis API
val imageAnalysisConfig = ImageAnalysisConfig.Builder()
.setTargetResolution(Size(1280, 720))
.build()
val imageAnalysis = ImageAnalysis(imageAnalysisConfig)
Image Analysis API
val imageAnalysisConfig = ImageAnalysisConfig.Builder()
.setTargetResolution(Size(1280, 720))
.build()
val imageAnalysis = ImageAnalysis(imageAnalysisConfig)
imageAnalysis.setAnalyzer({ image: ImageProxy, rotationDegrees: Int ->
// insert your code here.
})
Image Analysis API
val imageAnalysisConfig = ImageAnalysisConfig.Builder()
.setTargetResolution(Size(1280, 720))
.build()
val imageAnalysis = ImageAnalysis(imageAnalysisConfig)
imageAnalysis.setAnalyzer({ image: ImageProxy, rotationDegrees: Int ->
// insert your code here.
})
CameraX.bindToLifecycle(this as LifecycleOwner, imageAnalysis, preview)
Image Capture API (Simplified)
val imageCaptureConfig = ImageCaptureConfig.Builder()
.setTargetRotation(windowManager.defaultDisplay.rotation)
.build()
val imageCapture = ImageCapture(imageCaptureConfig)
CameraX.bindToLifecycle(this as LifecycleOwner,
imageCapture, imageAnalysis, preview)
Image Capture API (Advance)
val imageCaptureConfig = ImageCaptureConfig.Builder().apply {
setLensFacing(lensFacing)
setCaptureMode(CaptureMode.MIN_LATENCY)
// We request aspect ratio but no resolution to match preview config but letting
// CameraX optimize for whatever specific resolution best fits requested capture mode
setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
setTargetRotation(viewFinder.display.rotation)
}.build()
Image Capture API (Take Photo)
fun onClick() {
val file = File(...)
imageCapture.takePicture(file,
object : ImageCapture.OnImageSavedListener {
override fun onError(error: ImageCapture.UseCaseError,
message: String, exc: Throwable?) {
// insert your code here.
}
override fun onImageSaved(file: File) {
// insert your code here.
}
})
Add in build.gradle
dependencies {
// CameraX core library.
def camerax_version = "1.0.0-alpha02"
implementation "androidx.camera:camera-core:${camerax_version}"
// If you want to use Camera2 extensions.
implementation "androidx.camera:camera-camera2:${camerax_version}"
}
Extended
Kuala Lumpur
CameraX Extensions
CameraX Extensions
Apps using CameraX
Camera360
Snow (S10+ plus)
CameraX resources
Code Lab : https://codelabs.developers.google.com/codelabs/camerax-getting-started/#2
Sample App : https://github.com/android/camera/tree/master/CameraXBasic
Training : https://developer.android.com/training/camerax
Extended
Kuala Lumpur
ViewPager2
ViewPager2
- Uses RecyclerView
- Adapter
- Page Snap Helper
- PageChange callbacks
- onPageScrolled() 
- onPageSelected() 
- onPageScrollStateChanged() 
-
-
Extended
Kuala Lumpur
Implementing ViewPager2
ViewPager2
implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha01'
ViewPager2
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
ViewPager2
val adapter = WelcomeAdapter()
adapter.welcomeItems = listOf(WelcomeItem.WELCOME_ONE, WelcomeItem.WELCOME_TWO,
WelcomeItem.WELCOME_THREE)
view_pager.adapter = adapter
ViewPager2
androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL
ViewPager2
view_pager.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
// override desired callback functions
})
Extended
Kuala Lumpur
Demo
Learning material
Sample https://github.com/googlesamples/android-viewpager2
API doc : https://developer.android.com/jetpack/androidx/releases/viewpager2
Extended
Kuala Lumpur
ViewModel with SavedState
ViewModel with SavedState
- ViewModel objects can handle UI configuration change
- In case of process death, we use onSaveInstanceState()
- With ViewModel SavedState
- We can save UI state in ViewModel after process death and recover it
ViewModel with SavedState
dependencies {
implementation "androidx.lifecycle:lifecycle-extensions:2.1.0-alpha03"
kapt "androidx.lifecycle:lifecycle-compiler:2.1.0-alpha03"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$1.0.0-alpha01"
implementation "androidx.activity:activity-ktx:1.0.0-alpha05"
}
ViewModel with SavedState
//In order to set up a ViewModel to receive a SavedStateHandle you need to
// create them using a Factory that extends AbstractSavedStateVMFactory.
val vm = ViewModelProvider(this, SavedStateVMFactory(this))
.get(SavedStateViewModel::class.java)
ViewModel with SavedState
//After that your ViewModel can have a constructor that receives a
SavedStateHandle:
class SavedStateViewModel(private val state: SavedStateHandle) : ViewModel() {
... }
ViewModel with SavedState
/* Storing and retrieving values
The SavedStateHandle class has the methods you expect for a key-value map:
*/
get(String key)
contains(String key)
remove(String key)
set(String key, T value)
keys()
// Code lab : https://codelabs.developers.google.com/codelabs/android-lifecycles/#6
Extended
Kuala Lumpur
JetPack Compose
JetPack Compose
- A declarative toolkit for building UI
- Part of Android Open source project
- Two major components
- UI Library
- Compiler
JetPack compose
import androidx.compose.*
import androidx.ui.core.*
@Composable
fun Greeting(name: String) {
Text ("Hello $name!")
}
Learning material
Library https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/ui/README.md
Extended
Kuala Lumpur
Stable APIs
Navigation - Stable [sample]
Extended
Kuala Lumpur
WorkManager (Stable) [sample]
Extended
Kuala Lumpur
Thank You
Extended
Kuala Lumpur
Questions?

More Related Content

PDF
Exploring CameraX from JetPack
PDF
Improving app performance with Kotlin Coroutines
PDF
Building Modern Apps using Android Architecture Components
PDF
Jetpack, with new features in 2021 GDG Georgetown IO Extended
PDF
Building an app with Google's new suites
PDF
Workshop 26: React Native - The Native Side
PDF
Sharper Better Faster Dagger ‡ - Droidcon SF
PDF
Advanced Dagger talk from 360andev
Exploring CameraX from JetPack
Improving app performance with Kotlin Coroutines
Building Modern Apps using Android Architecture Components
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Building an app with Google's new suites
Workshop 26: React Native - The Native Side
Sharper Better Faster Dagger ‡ - Droidcon SF
Advanced Dagger talk from 360andev

What's hot (20)

PDF
Create Modern Apps with Android Jetpack
PPTX
React native by example by Vadim Ruban
PDF
A friend in need - A JS indeed
PDF
Workshop 25: React Native - Components
PPTX
GDG Kuwait - Modern android development
PDF
Daggerate your code - Write your own annotation processor
PDF
Intro to Retrofit 2 and RxJava2
PPTX
Angular2 + rxjs
PDF
AngularJS - TechTalk 3/2/2014
PPTX
Angular modules in depth
PDF
Declarative UIs with Jetpack Compose
PPTX
Dagger 2. The Right Way to Dependency Injections
PDF
Dagger 2. Right way to do Dependency Injection
PDF
Android Jetpack + Coroutines: To infinity and beyond
PDF
Building maintainable app
PDF
Angular performance slides
PDF
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
PPTX
Angular Workshop_Sarajevo2
PPTX
Making React Native UI Components with Swift
PDF
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
Create Modern Apps with Android Jetpack
React native by example by Vadim Ruban
A friend in need - A JS indeed
Workshop 25: React Native - Components
GDG Kuwait - Modern android development
Daggerate your code - Write your own annotation processor
Intro to Retrofit 2 and RxJava2
Angular2 + rxjs
AngularJS - TechTalk 3/2/2014
Angular modules in depth
Declarative UIs with Jetpack Compose
Dagger 2. The Right Way to Dependency Injections
Dagger 2. Right way to do Dependency Injection
Android Jetpack + Coroutines: To infinity and beyond
Building maintainable app
Angular performance slides
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Angular Workshop_Sarajevo2
Making React Native UI Components with Swift
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
Ad

Similar to What’s new in Android JetPack (20)

PDF
camera_x_beyond_alpha
PDF
CameraX, MLKit and AutoML at DevFest Cebu 2019
PDF
Android Jetpack - Google IO Extended Singapore 2018
PDF
CameraX, MLKit and AutoML at DevFest Songdo 2019
PDF
Oleksandr Tolstykh
PDF
Android camera2
PPTX
Android Camera Presentation on Benifits and disadvantages
PDF
Model View Intent on Android
PDF
How Android API's evolved: Viewflipper vs ViewPager
PDF
Droidcon NYC 2014: Building Custom Camera Applications
PDF
Droidcon NYC 2014: Building Custom Camera Applications
DOCX
PDF
Arquitetando seu app Android com Jetpack
KEY
Android workshop
PDF
Gabor Varadi - Reactive State Management with Jetpack Components
PPTX
How to create a camera2
PPTX
Reactive state management with Jetpack Components
PDF
Camera2 API: Overview
PPTX
What's new in Android, Igor Malytsky ( Google Post I|O Tour)
DOCX
package org dev
camera_x_beyond_alpha
CameraX, MLKit and AutoML at DevFest Cebu 2019
Android Jetpack - Google IO Extended Singapore 2018
CameraX, MLKit and AutoML at DevFest Songdo 2019
Oleksandr Tolstykh
Android camera2
Android Camera Presentation on Benifits and disadvantages
Model View Intent on Android
How Android API's evolved: Viewflipper vs ViewPager
Droidcon NYC 2014: Building Custom Camera Applications
Droidcon NYC 2014: Building Custom Camera Applications
Arquitetando seu app Android com Jetpack
Android workshop
Gabor Varadi - Reactive State Management with Jetpack Components
How to create a camera2
Reactive state management with Jetpack Components
Camera2 API: Overview
What's new in Android, Igor Malytsky ( Google Post I|O Tour)
package org dev
Ad

More from Hassan Abid (14)

PDF
[IO Extended KL] On-Device AI: Is It Time to Go All-In, or Do We Still Need t...
PDF
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
PDF
DevFest SG 2024 - What’s new in On-device Generative AI
PDF
What’s new in Android: Embracing era of Generative AI
PDF
Android 101 - Kotlin ( Future of Android Development)
PDF
Kotlin for Android Developers
PDF
Recap of Android Dev Summit 2018
PDF
What's new in Android Pie
PDF
Django for mobile applications
PDF
VR Video Apps on Daydream
PDF
Best Practices in Media Playback
PDF
ExoPlayer for Application developers
PPTX
Android n preview
PDF
Introduction to Pakistan
[IO Extended KL] On-Device AI: Is It Time to Go All-In, or Do We Still Need t...
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
DevFest SG 2024 - What’s new in On-device Generative AI
What’s new in Android: Embracing era of Generative AI
Android 101 - Kotlin ( Future of Android Development)
Kotlin for Android Developers
Recap of Android Dev Summit 2018
What's new in Android Pie
Django for mobile applications
VR Video Apps on Daydream
Best Practices in Media Playback
ExoPlayer for Application developers
Android n preview
Introduction to Pakistan

Recently uploaded (20)

PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Transform Your Business with a Software ERP System
PDF
System and Network Administration Chapter 2
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
top salesforce developer skills in 2025.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Reimagine Home Health with the Power of Agentic AI​
Wondershare Filmora 15 Crack With Activation Key [2025
Transform Your Business with a Software ERP System
System and Network Administration Chapter 2
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Navsoft: AI-Powered Business Solutions & Custom Software Development
How Creative Agencies Leverage Project Management Software.pdf
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
top salesforce developer skills in 2025.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Operating system designcfffgfgggggggvggggggggg
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
CHAPTER 2 - PM Management and IT Context
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)

What’s new in Android JetPack