SlideShare a Scribd company logo
Android 6.0
Permission
change
彥彬
Permission before 6.0
Android 6.0 permission change
大部分的人應該都這樣做
Android 6.0 permission change
Android 6.0 permission change
Apps support 6.0
Android 6.0 permission change
Android 6.0 permission change
APP安裝行為
1. 6.0以下手機 + 支援6.0的APP
2. 6.0 以下手機 + 不支援6.0的APP
3. 6.0 以上手機 + 不支援 6.0 的APP
4. 6.0 以上手機 + 支援 6.0 的 APP
安裝時需要同意權限
安裝時需要同意權限
安裝時需要同意權限
安裝時不需要同意權限
Permission overview
Permission category
● Normal permission
● Dangerous permission
Normal Permission
● 只需要在 manifest 宣告就好
● 使用者不必同意該權限
● 使用者不會知道使用了該權限
Dangerous Permission
● 使用者可自行決定是否使用該權限
● 可在設定中關閉
Permission group
● Dangerous permission 分成 9 組
● 一次同意整組權限
Permission groups
CALENDAR
● READ_CALENDAR
● WRITE_CALENDAR
CAMERA
● CAMERA
CONTACTS
● READ_CONTACTS
● WRITE_CONTACTS
● GET_ACCOUNTS
LOCATION
● ACCESS_FINE_LOCATION
● ACCESS_COARSE_LOCATION
MICROPHONE
● RECORD_AUDIO
PHONE
● READ_PHONE_STATE
● CALL_PHONE
● READ_CALL_LOG
● WRITE_CALL_LOG
● ADD_VOICEMAIL
● USE_SIP
● PROCESS_OUTGOING_CALLS
SENSORS
● BODY_SENSORS
SMS
● SEND_SMS
● RECEIVE_SMS
● READ_SMS
● RECEIVE_WAP_PUSH
● RECEIVE_MMS
STORAGE
● READ_EXTERNAL_STORAGE
● WRITE_EXTERNAL_STORAGE
Permission API
API 使用流程
checkSelfPermission
繼續執行
requestPermissions
PERMISSION_GRANTED
PERMISSION_DENIED
onRequest
PermissionsResult
Error handling
PERMISSION_GRANTED
PERMISSION_DENIED
APIs
int Context#checkSelfPermission(String permission)
void Activity/Fragment#RequestPermissions(String[] permissions, int
requestCode)
void Activity/Fragment#onRequestPermissionsResult(int requestCode, String[]
permissions, int[] grantResults )
boolean Activity/Fragment#shouldShowRequestPermissionRationale(String
permission)
要求權限
if (checkSelfPermission(Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
處理回應
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the
// contacts-related task you need to do.
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
}
return;
}
}
}
處理“不要再詢問我”
shouldShowRequestPermissionRationale(permission) == false
相容性
● 需要檢查 Build.VERSION_CODE < 23
● 或是使用 Support v4
Asking for permission
一般時機
● 需要時再要求(map, 定位...)
● 永遠不要有預設立場,在onCreate檢查
● 發送 Intent 時也需要權限
Service?
1. 一開APP 馬上要求權限
2. 需要時發出Notification
3. 隨時提醒使用者
Extras
建議
● 盡量隔離外部資源
● Permission API再包裝一層
Screen overlay
● 無法更改權限屬正常行為
偷偷被藏起來的權限...
● Manifest.permission.WRITE_SETTINGS
● Manifest.permission.CHANGE_NETWORK_STATE
● Manifest.permission.SYSTEM_ALERT_WINDOW
pre23| preinstalled permissions
● Android M 之後預設無法使用
● Manifest.permission.WRITE_SETTINGS 可以經由 intent
ACTION_MANAGE_WRITE_SETTINGS 開啟
Reference
https://www.youtube.com/watch?v=5xVh-
7ywKpE&index=9&list=PLWz5rJ2EKKc_Tt7q77qwyKRgytF1RzRx8

More Related Content

Viewers also liked (20)

ODP
Android training day 4
Vivek Bhusal
 
PPTX
Tips dan Third Party Library untuk Android - Part 1
Ibnu Sina Wardy
 
PPTX
Android secuirty permission - upload
Bin Yang
 
PPTX
Android AsyncTask Tutorial
Perfect APK
 
ODP
Json Tutorial
Napendra Singh
 
PDF
Basic Android Push Notification
Chaiyasit Tayabovorn
 
PDF
Android new permission model
Takuji Nishibayashi
 
PPTX
JSON overview and demo
Flatiron School
 
PDF
Simple JSON parser
Dongjun Lee
 
PDF
App Permissions
Shinobu Okano
 
PDF
Android webservices
Krazy Koder
 
ODP
Android porting for dummies @droidconin 2011
pundiramit
 
PPTX
Android json parser tutorial – example
Rajat Ghai
 
PDF
Android security
Krazy Koder
 
PPTX
Android - Bluetooth
Arthur Emanuel
 
PDF
Android Security Development - Part 2: Malicious Android App Dynamic Analyzi...
Cheng-Yi Yu
 
PDF
Securing android applications
Jose Manuel Ortega Candel
 
PPTX
Webservice for android ppt
santosh lamba
 
PDF
Connecting to Web Services on Android
sullis
 
PPTX
Permission in Android Security: Threats and solution
Tandhy Simanjuntak
 
Android training day 4
Vivek Bhusal
 
Tips dan Third Party Library untuk Android - Part 1
Ibnu Sina Wardy
 
Android secuirty permission - upload
Bin Yang
 
Android AsyncTask Tutorial
Perfect APK
 
Json Tutorial
Napendra Singh
 
Basic Android Push Notification
Chaiyasit Tayabovorn
 
Android new permission model
Takuji Nishibayashi
 
JSON overview and demo
Flatiron School
 
Simple JSON parser
Dongjun Lee
 
App Permissions
Shinobu Okano
 
Android webservices
Krazy Koder
 
Android porting for dummies @droidconin 2011
pundiramit
 
Android json parser tutorial – example
Rajat Ghai
 
Android security
Krazy Koder
 
Android - Bluetooth
Arthur Emanuel
 
Android Security Development - Part 2: Malicious Android App Dynamic Analyzi...
Cheng-Yi Yu
 
Securing android applications
Jose Manuel Ortega Candel
 
Webservice for android ppt
santosh lamba
 
Connecting to Web Services on Android
sullis
 
Permission in Android Security: Threats and solution
Tandhy Simanjuntak
 

More from 彥彬 洪 (12)

PDF
Rx java testing patterns
彥彬 洪
 
PDF
Rxjava2 custom operator
彥彬 洪
 
PDF
Koin
彥彬 洪
 
PDF
Android material theming
彥彬 洪
 
PDF
Kotlin in practice
彥彬 洪
 
PDF
Why use dependency injection
彥彬 洪
 
PDF
Jsr310
彥彬 洪
 
PDF
ThreeTen
彥彬 洪
 
PDF
科特林λ學
彥彬 洪
 
PDF
Mvp in practice
彥彬 洪
 
PDF
設定android 測試環境
彥彬 洪
 
PDF
Green dao
彥彬 洪
 
Rx java testing patterns
彥彬 洪
 
Rxjava2 custom operator
彥彬 洪
 
Android material theming
彥彬 洪
 
Kotlin in practice
彥彬 洪
 
Why use dependency injection
彥彬 洪
 
Jsr310
彥彬 洪
 
ThreeTen
彥彬 洪
 
科特林λ學
彥彬 洪
 
Mvp in practice
彥彬 洪
 
設定android 測試環境
彥彬 洪
 
Green dao
彥彬 洪
 
Ad

Recently uploaded (20)

PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Ad

Android 6.0 permission change