SlideShare a Scribd company logo
1 of 78
Download to read offline
Somkiat Khitwongwattana
@akexorcist
What's new in Android O
API 26
Timeline
March April May June July Q3
DP1 DP2 DP3
Final APIs
DP4 Final
Release
Timeline
March April May June July Q3
DP1 DP2 DP3
Final APIs
DP4 Final
Release
Background Execution Limits
Background Execution Limits
• Background Service Limitations
• Broadcast Limitations
แบ่งเป็น 2 รูปแบบ
Background Service Limitations
• App ที่มี Activity แสดงอยู่บนหน้าจอถือว่าเป็น Foreground App
• App ที่มี Foreground Service ทํางานอยู่ถือว่าเป็น Foreground App
• App ที่เชื่อมต่อกับ Foreground App ก็ถือว่าเป็น Foreground App
• นอกเหนือจากนี้ถือว่าเป็น Background App
อะไรที่เป็น Background App ซวย!!
Background Service Limitations
เมื่อ App เข้าสู่การทํางานแบบ Background App
จะทํางานได้ซักพักหนึ่งแล้วก็จะหยุดทํางานโดยอัตโนมัติ
ซวยยังไง?
Background Service Limitations
• เรียกใช้งาน FCM แบบ High Priority
• รับ Broadcast ที่เกี่ยวกับ User โดยตรง เช่น SMS
• เรียกใช้งาน Notification โดยกําหนด Pending Intent ไว้ด้วย
• จะไม่ถูกสั่งให้หยุดทํางาน เพราะติดต่อกับส่วนที่แสดงผลต่อผู้ใช้โดยตรง
เว้นแต่ว่า Background App นั้น...
• Broadcast Receiver ที่เป็น Implicit Broadcast 

ที่ประกาศไว้ใน Android Manifest จะไม่ทํางานอีกต่อไป
• มี Implicit Broadcast บางตัวที่ได้รับการยกเว้น
Broadcast Limitations
Broadcast Receiver ก็ซวยเช่นกัน
• ACTION_LOCKED_BOOT_COMPLETED
• ACTION_BOOT_COMPLETED
• ACTION_LOCALE_CHANGED
• ACTION_HEADSET_PLUG
• ACTION_MEDIA_MOUNTED
Broadcast Limitations
ตัวอย่าง Implicit Broadcast ที่ไม่ซวย
• ACTION_USB_DEVICE_ATTACHED
• ACTION_USB_DEVICE_DETACHED
• ACTION_NEW_OUTGOING_CALL
• SMS_RECEIVED_ACTION
• ฯลฯ
ดูเพิ่มเติมได้ที่
https://developer.android.com/preview/features/background-broadcasts.html
• JobScheduler
• Firebase JobDispatcher
How do we deal with it?
วิธีการรับมือ
Background Location Limits
Background Location Limits
• App ที่มี Activity แสดงอยู่บนหน้าจอถือว่าเป็น Foreground App
• App ที่มี Foreground Service ทํางานอยู่ถือว่าเป็น Foreground App
• App ที่เชื่อมต่อกับ Foreground App ก็ถือว่าเป็น Foreground App
• นอกเหนือจากนี้ถือว่าเป็น Background App
อะไรที่เป็น Background App ก็ซวยเหมือนเดิม
• ทําให้ App เป็น Foreground App ซะ อย่างเช่นทําเป็น Foreground Service ที่ผูกเข้ากับ
Notification เพื่อให้ผู้ใช้รู้ว่ากําลังจับตําแหน่งอยู่
• แทนวิธีแบบเดิมๆที่ทําเป็น Background App แล้วคอยจับตําแหน่งอยู่เงียบๆตลอดเวลา
How do we deal with it?
วิธีการรับมือ
Notification
Notification Channels
Problem
Notification Channels
Notification Channel Groups
Create Notification
Notification Badge
Autofill Framework
Autofill Framework
ไม่ต้องทําอะไร ถ้าไม่ได้ทําในฝั่งของ Service
Picture-in-Picture
Picture-in-Picture Mode
Picture-in-Picture Mode
AndroidManifest.xml
Fonts
Fonts in XML
res/font/th_sarabun_new.xml
Fonts in XML
Fonts in XML
XML
Fonts in XML
Programmatically (API 26)
Fonts in XML
Programmatically (Support Library)
Support Library v26.0.0-beta1 ขึ้นไป
Downloadable Fonts
API 26
Downloadable Fonts
Support Library
Google Play Services v11 ขึ้นไป
Downloadable Fonts
• Font Certificates
• Font Request
• Preloaded (Optional)
Required
Downloadable Fonts
Font Certificates
res/values/any_name_as_you_want.xml
Downloadable Fonts
Font Request (XML)
res/font/should_be_font_family_name.xml
Downloadable Fonts
Font Request (Programmatically)
Downloadable Fonts
Font Request (Programmatically)
Downloadable Fonts
Preloaded
res/values/preloaded_fonts.xml (any name as you want)
Downloadable Fonts
Preloaded
AndroidManifest.xml
Downloadable Fonts
Downloadable Fonts
Autosizing TextView
Autosizing TextView
Autosizing TextViewCommon TextView
Autosizing TextView
• Default
• Granularity
• Preset Sizes
3 Types
Autosizing TextView
Default Autosizing (API 26)
Autosizing TextView
Default Autosizing (Support Library)
Autosizing TextView
Granularity Autosizing (Support Library)
Autosizing TextView
Preset Sizes Autosizing (Support Library)
res/values/arrays.xml
Autosizing TextView
Preset Sizes Autosizing (Support Library)
Adaptive Icons
Adaptive Icons
Problem
Adaptive Icons
Background Foreground
Adaptive Icons
res/drawable/any_name_as_you_want.xml
Adaptive Icons
Adaptive Icons
• Foreground และ Background ควรมีขนาด 108x108 dp
• พื้นที่ในการแสดงภาพของ Foreground ควรอยู่ใน 72x72dp
• ระบบจะเผื่อพื้นที่ไว้อีก 18dp สําหรับแสดงเอฟเฟคเคลื่อนไหว
• เฉพาะ API 26 ขึ้นไปเท่านั้น
Should know
Pinning Shortcuts & Widgets
Pinning Shortcuts
Pinning Shortcuts
Pinning Shortcuts
Pinning Shortcuts
Pinning Widgets
Pinning Widgets
res/xml/hello_app_widget.xml
Pinning Widgets
AndroidManifest.xml
Pinning Widgets
Pinning Widgets
อื่นๆ
findViewById()
API 26 ขึ้นไป
Support Library v26.0.1-beta1 ขึ้นไป
Multi-display Support
• การทํางานเหมือน Multi-Window
• แอพไหนรองรับ Multi-Window ก็จะรองรับ Multi-display
• ออกแบบ Layout ให้รองรับการปรับขนาดหน้าจอแบบอิสระ
• จัดการกับ Lifecycle ให้ดีๆ
• อย่าลืมเรื่อง Configuration Changes
• อย่าลืมเรื่อง Instance State ด้วยเหมือนกัน
Layout Margins & Padding
• layout_marginVertical = layout_marginTop + layout_marginBottom
• layout_marginHorizontal = layout_marginLeft + layout_marginRight
• paddingVertical = paddingTop + paddingBottom
• paddingHorizontal = paddingLeft + paddingRight
ไม่มีผลกับ
layout_marginStart, layout_marginEnd, paddingStart และ paddingEnd.
App Categories
Google Safe Browsing API
Custom Data Store
Custom Data Store
Backward Compatibility
• Fonts in XML
• Downloadable Fonts
• Autosizing TextView
• findViewById
References
Android O Developer Preview
https://developer.android.com/preview/index.html
Android O Features and APIs
https://developer.android.com/preview/api-overview
Migrating Apps to Android O
https://developer.android.com/preview/migration.html
Sample Codes
https://developer.android.com/samples/index.html
Have Fun!

More Related Content

More from Somkiat Khitwongwattana

More from Somkiat Khitwongwattana (18)

What's new in Android - Google I/O Extended Bangkok 2022
What's new in Android - Google I/O Extended Bangkok 2022What's new in Android - Google I/O Extended Bangkok 2022
What's new in Android - Google I/O Extended Bangkok 2022
 
Canvas API in Android
Canvas API in AndroidCanvas API in Android
Canvas API in Android
 
Get Ready for Target SDK Version 29 and 30
Get Ready for Target SDK Version 29 and 30Get Ready for Target SDK Version 29 and 30
Get Ready for Target SDK Version 29 and 30
 
What's new in Android P @ I/O Extended Bangkok 2018
What's new in Android P @ I/O Extended Bangkok 2018What's new in Android P @ I/O Extended Bangkok 2018
What's new in Android P @ I/O Extended Bangkok 2018
 
New things that android developer should not miss in 2019
New things that android developer should not miss in 2019New things that android developer should not miss in 2019
New things that android developer should not miss in 2019
 
Architecture Components In Real Life Season 2
Architecture Components In Real Life Season 2Architecture Components In Real Life Season 2
Architecture Components In Real Life Season 2
 
Bitmap management like a boss
Bitmap management like a bossBitmap management like a boss
Bitmap management like a boss
 
Android Architecture Component in Real Life
Android Architecture Component in Real LifeAndroid Architecture Component in Real Life
Android Architecture Component in Real Life
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
 
Deep Dive Into Repository - Android Architecture Components
Deep Dive Into Repository - Android Architecture ComponentsDeep Dive Into Repository - Android Architecture Components
Deep Dive Into Repository - Android Architecture Components
 
Introduction to Architecture Components @ Google I/O Extended Bangkok 2017
Introduction to Architecture Components @ Google I/O Extended Bangkok 2017Introduction to Architecture Components @ Google I/O Extended Bangkok 2017
Introduction to Architecture Components @ Google I/O Extended Bangkok 2017
 
Pokemon GO 101@Nextzy
Pokemon GO 101@NextzyPokemon GO 101@Nextzy
Pokemon GO 101@Nextzy
 
Advance Android Layout Walkthrough
Advance Android Layout WalkthroughAdvance Android Layout Walkthrough
Advance Android Layout Walkthrough
 
Interface Design for Mobile Application
Interface Design for Mobile ApplicationInterface Design for Mobile Application
Interface Design for Mobile Application
 
Smart Lock for Password @ Game DevFest Bangkok 2015
Smart Lock for Password @ Game DevFest Bangkok 2015Smart Lock for Password @ Game DevFest Bangkok 2015
Smart Lock for Password @ Game DevFest Bangkok 2015
 
Whats new in Android Development Tools @ I/O Rewind Bangkok
Whats new in Android Development Tools @ I/O Rewind BangkokWhats new in Android Development Tools @ I/O Rewind Bangkok
Whats new in Android Development Tools @ I/O Rewind Bangkok
 
What's new in Google Play Services @ I/O Rewind Bangkok
What's new in Google Play Services @ I/O Rewind BangkokWhat's new in Google Play Services @ I/O Rewind Bangkok
What's new in Google Play Services @ I/O Rewind Bangkok
 
ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]
 

What's new in Android O @ Google I/O Extended Bangkok 2017