Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Runtime permissions in Android 11
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hiroyuki Kusu
November 27, 2020
Programming
500
0
Share
Runtime permissions in Android 11
Yumemi.apk #2 (
https://yumemi.connpass.com/event/191284/
) の資料
Hiroyuki Kusu
November 27, 2020
More Decks by Hiroyuki Kusu
See All by Hiroyuki Kusu
モノレポのプルリクエストに最近、導入したもの
hkusu
2
580
GitHub composite actions
hkusu
2
430
Android の静的解析における SARIF ファイルの活用
hkusu
0
5.5k
CI_でライブラリのバージョンの変化をレポートする.pdf
hkusu
0
410
Maestro を GitHub Actions で動かす 〜Android編〜
hkusu
1
1.7k
Android の CI(GitHub Actions)の改善で、最近やったこと
hkusu
0
720
Tauri Mobile で生成される Android のコードを見てみる
hkusu
0
1.5k
Custom GitHub Actions を作って Organization 内で共有する
hkusu
1
590
GitHub Actions でユニットテストの結果をレポートする
hkusu
0
3.9k
Other Decks in Programming
See All in Programming
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
🦞OpenClaw works with AWS
licux
1
350
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.1k
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
1
680
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.7k
認証統合から始めるフロントエンドの機能単位開発 — マイクロサービス思想の適用
koukimiura
0
100
継続的な負荷検証を目指して
pyama86
3
1k
【26新卒研修】OpenAPI/Swagger REST API研修
dip_tech
PRO
0
150
The Less-Told Story of Socket Timeouts
coe401_
3
1.1k
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
160
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
5
4.9k
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.9k
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
A Tale of Four Properties
chriscoyier
163
24k
The Language of Interfaces
destraynor
162
26k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Into the Great Unknown - MozCon
thekraken
41
2.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Abbi's Birthday
coloredviolet
2
7.5k
The SEO Collaboration Effect
kristinabergwall1
1
440
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
500
Transcript
Runtime permissions in Android 11 2020.11.27 YUMEMI.apk #2 Hiroyuki Kusu
( @hkusu_ )
About me
• 1ճ͚ͩͷΞΫηεڐՄΦϓγϣϯ͕ՃʢҐஔใɺϚΠΫɺΧϝϥͷ߹ͷΈʣ • ෳճڋ൱͢Δͱʮࠓޙ֬ೝ͠ͳ͍ʯঢ়ଶͱͳΔ • ݖݶΛࣗಈతʹϦηοτ͢Δઃఆ͕Ճ ΞϓϦͷ targetSdkVersion ʹؔͳ͘ɺAPI Level
30 Ҏ্ͷσόΠεͰ
Ґஔใͷ߹
※ ΞϓϦͷ targetSdkVersion ͕ 30Ҏ্ͷ߹σϑΥϧτͰࣗಈϦηοτ͕ON
ैདྷͲ͓ΓɺػೳΛར༻͢ΔલͰ permission Λ औಘ͢ΔίʔυΛॻ͍͍ͯΕɺͱΓ͋͑ͣେৎͦ͏ɻ
class MainFragment : Fragment(R.layout.main_fragment) { // ... override fun onViewCreated(view:
View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) // FragmentͷੜϑΣʔζͰొ͠ͳ͍ͱΤϥʔʹͳΔͷͰҙ val locationPermission = registerForActivityResult( ActivityResultContracts.RequestPermission() ) { isGranted -> when { // طʹڐՄ͞Ε͍ͯͨ or μΠΞϩά͕දࣔ͞Ε[ΞϓϦͷ༻࣌ͷΈ]·ͨ[ࠓճͷΈ]͕ԡԼ͞Εͨ isGranted -> { // ... } // طʹڋ൱͞Ε͍ͯͨ or μΠΞϩά͕දࣔ͞Ε[ڐՄ͠ͳ͍]͕ԡԼ͞Εͨ else -> { // ... } } } button.setOnClickListener { locationPermission.launch(Manifest.permission.ACCESS_FINE_LOCATION) } ※ ActivityResultContracts androidx.activity ͷ 1.2.0ɺandroidx.fragment ͷ 1.3.0 Ҏ߱Ͱར༻͕Մ ϘλϯΛԡԼͨ͠ΒҐஔใΛར༻ͨ͠ԿΒ͔ͷॲཧΛ࣮ߦ͢Δྫɿ
• ContextCompat.checkSelfPermission() • ݱ࣌Ͱݖݶ͕ڐՄ͞Ε͍ͯΔ͔ • ActivityCompat.shouldShowRequestPermissionRationale() • ʮࠓޙ֬ೝ͠ͳ͍ʯঢ়ଶ͔ • PackageManager#isAutoRevokeWhitelisted()
• ݖݶͷࣗಈϦηοτ͕ONͰ͋Δ͔ • ͨͩ͠৽͍͠APIͳͷͰҎԼͷ߹ͷΈར༻͕Մೳ • compileSdkVersion ͕ 30Ҏ্ • API Level 30Ҏ্ͷσόΠε • Build.VERSION.SDK_INT • σόΠεͷ API Level • 30ະຬैདྷͷpermissionͷ༷ͷ··ͳͷͰUIΛ͚Δ߹ ͨͩ͠ɺϢʔβʹڐՄΛଅ͢ͳΒɺ ͋ͨΓΛར༻ͯ͠ಋઢจݴΛ੍ޚ͠ɺUIΛͨ͠ํ͕Αͦ͞͏ɻ
Thank you ! @hkusu_