What's new in android 2018, a content created by Google, and conducted by Shady Selim, for developers attending DevFest all across Egypt.
It combines all the latest Android for Developers updates
61. // A simple Worker
class UploadPhotoWorker : Worker() {
override fun doWork(): WorkerResult {
uploadPhoto()
return WorkerResult.SUCCESS
}
}
SUCCESS
FAILURE
RETRY
Runs on a background thread
62. // Creating a work request and enqueuing it
val request: WorkRequest =
OneTimeWorkRequestBuilder<UploadPhotoWorker>().build()
WorkManager.getInstance().enqueue(request)
Ω
63. What if you lose connectivity?
Use constraints!
64. // Creating a work request with network constraints
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val request =
OneTimeWorkRequestBuilder<UploadPhotoWorker>()
.setConstraints(constraints)
.build()
WorkManager.getInstance().enqueue(request)
81. HelpFragment.kt
val args : HelpFragmentArgs = HelpFragmentArgs.fromBundle(arguments)
val screenName: String = args.screenName
val category: Int = args.category
91. Android KTX
Part of Jetpack
Concise, readable code.
A suite of libraries
Android KTX, Testing KTX, ...
92. Background Text Measurement
Text measurement is expensive
Up to 80 to 90% of the draw/measure/layout loop
Pre-computed text API offloads most of the work to a worker thread
PrecomputedText.create(...)
94. val tv: TextView
// Distance from top to first baseline
tv.firstBaselineToTopHeight = distancePx
// Distance from bottom to last baseline
tv.lastBaselineToBottomHeight = distancePx
101. Slices
A new approach to remote content
● Within an app or between apps
● Structured data, flexible templates
● Interactive, updatable
● Backwards-compatible!
● (Support Library, KitKat/API 19+)
102. Actions
Deep links into your app
● “shortcuts with parameters”
● “a visible Intent”
Define actions in actions.xml
Register with App Indexing to show as on-device search results
103. Notifications
People love messages
…so we focused on MessagingStyle
● Inline images/stickers
● Participant images
● Smart reply UI
● RemoteInput.setChoices()
And more!