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
Hiroyuki Kusu
November 27, 2020
Programming
0
460
Runtime permissions in Android 11
Yumemi.apk #2 (
https://yumemi.connpass.com/event/191284/
) の資料
Hiroyuki Kusu
November 27, 2020
Tweet
Share
More Decks by Hiroyuki Kusu
See All by Hiroyuki Kusu
モノレポのプルリクエストに最近、導入したもの
hkusu
2
460
GitHub composite actions
hkusu
2
330
Android の静的解析における SARIF ファイルの活用
hkusu
0
4.9k
CI_でライブラリのバージョンの変化をレポートする.pdf
hkusu
0
330
Maestro を GitHub Actions で動かす 〜Android編〜
hkusu
1
1.4k
Android の CI(GitHub Actions)の改善で、最近やったこと
hkusu
0
590
Tauri Mobile で生成される Android のコードを見てみる
hkusu
0
1.3k
Custom GitHub Actions を作って Organization 内で共有する
hkusu
1
510
GitHub Actions でユニットテストの結果をレポートする
hkusu
0
3.4k
Other Decks in Programming
See All in Programming
파급효과: From AI to Android Development
l2hyunwoo
0
150
KANNA Android の技術的課題と取り組み
watabee
0
160
KawaiiLT 登壇資料 キャリアとモチベーション
hiiragi
0
160
iOSアプリで測る!名古屋駅までの 方向と距離
ryunakayama
0
140
eBPF超入門「o11yに使える」とは (20250424_eBPF_o11y)
thousanda
1
100
flutter_kaigi_mini_4.pdf
nobu74658
0
130
Browser and UI #2 HTML/ARIA
ken7253
2
160
Ruby's Line Breaks
yui_knk
3
2.2k
[NG India] Event-Based State Management with NgRx SignalStore
markostanimirovic
1
180
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
2
850
カオスに立ち向かう小規模チームの装備の選択〜フルスタックTSという装備の強み _ 弱み〜/Choosing equipment for a small team facing chaos ~ Strengths and weaknesses of full-stack TS~
bitkey
1
120
「理解」を重視したAI活用開発
fast_doctor
0
230
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
Docker and Python
trallard
44
3.4k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.5k
It's Worth the Effort
3n
184
28k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Practical Orchestrator
shlominoach
187
11k
The Pragmatic Product Professional
lauravandoore
33
6.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.4k
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_