$30 off During Our Annual Pro Sale. View Details »
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
440
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
410
GitHub composite actions
hkusu
2
280
Android の静的解析における SARIF ファイルの活用
hkusu
0
4.3k
CI_でライブラリのバージョンの変化をレポートする.pdf
hkusu
0
280
Maestro を GitHub Actions で動かす 〜Android編〜
hkusu
0
1.2k
Android の CI(GitHub Actions)の改善で、最近やったこと
hkusu
0
540
Tauri Mobile で生成される Android のコードを見てみる
hkusu
0
1.3k
Custom GitHub Actions を作って Organization 内で共有する
hkusu
1
470
GitHub Actions でユニットテストの結果をレポートする
hkusu
0
3.2k
Other Decks in Programming
See All in Programming
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
190
Leverage LLMs in Java with LangChain4j and Quarkus
hollycummins
0
110
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
1
150
Arm移行タイムアタック
qnighy
0
390
Develop iOS apps with Neovim / vimconf_2024
uhooi
1
120
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
3.7k
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
420
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
720
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
140
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1k
チームにとって最適なスキルアップ施策とは何か/what-is-the-best-skill-up-approach-for-team
nobuoooo
0
160
Missing parts when designing and implementing Android UI
ericksli
0
370
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.3k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Six Lessons from altMBA
skipperchong
27
3.5k
Statistics for Hackers
jakevdp
796
220k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Producing Creativity
orderedlist
PRO
341
39k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Site-Speed That Sticks
csswizardry
0
88
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
How to Ace a Technical Interview
jacobian
276
23k
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_