码迷,mamicode.com
首页 > 移动开发 > 详细

Android 6.0新特性:权限

时间:2016-01-04 22:14:26      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:

6.0之前是install time permissions model,6.0之后取是runtime permissions model。
后者在安装的时候会跟用户显示所需要的权限,并在app运行的时候去申请权限。

Android将系统权限分成了四个保护等级normal,dangerous,signature,signatureOrSystem。
最常见的是normal permissiondangerous permission两类。

Normal permission:这类权限可以在app安装期间被默认赋予
  1. android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
  2. android.permission.ACCESS_NETWORK_STATE
  3. android.permission.ACCESS_NOTIFICATION_POLICY
  4. android.permission.ACCESS_WIFI_STATE
  5. android.permission.ACCESS_WIMAX_STATE
  6. android.permission.BLUETOOTH
  7. android.permission.BLUETOOTH_ADMIN
  8. android.permission.BROADCAST_STICKY
  9. android.permission.CHANGE_NETWORK_STATE
  10. android.permission.CHANGE_WIFI_MULTICAST_STATE
  11. android.permission.CHANGE_WIFI_STATE
  12. android.permission.CHANGE_WIMAX_STATE
  13. android.permission.DISABLE_KEYGUARD
  14. android.permission.EXPAND_STATUS_BAR
  15. android.permission.FLASHLIGHT
  16. android.permission.GET_ACCOUNTS
  17. android.permission.GET_PACKAGE_SIZE
  18. android.permission.INTERNET
  19. android.permission.KILL_BACKGROUND_PROCESSES
  20. android.permission.MODIFY_AUDIO_SETTINGS
  21. android.permission.NFC
  22. android.permission.READ_SYNC_SETTINGS
  23. android.permission.READ_SYNC_STATS
  24. android.permission.RECEIVE_BOOT_COMPLETED
  25. android.permission.REORDER_TASKS
  26. android.permission.REQUEST_INSTALL_PACKAGES
  27. android.permission.SET_TIME_ZONE
  28. android.permission.SET_WALLPAPER
  29. android.permission.SET_WALLPAPER_HINTS
  30. android.permission.SUBSCRIBED_FEEDS_READ
  31. android.permission.TRANSMIT_IR
  32. android.permission.USE_FINGERPRINT
  33. android.permission.VIBRATE
  34. android.permission.WAKE_LOCK
  35. android.permission.WRITE_SYNC_SETTINGS
  36. com.android.alarm.permission.SET_ALARM
  37. com.android.launcher.permission.INSTALL_SHORTCUT
  38. com.android.launcher.permission.UNINSTALL_SHORTCUT

dangerous permission:这类权限必须在运行的时候申请
  1. CALENDARREAD_CALENDAR;WRITE_CALENDAR
  2. CAMERACAMERA
  3. CONTACTSREAD_CONTACTS;WRITE_CONTACTS;GET_ACCOUNTS
  4. LOCATION:ACCESS_FINE_LOCATION;ACCESS_COARSE_LOCATION
  5. MICROPHONE:RECORD_AUDIO
  6. PHONE:READ_PHONE_STATE;CALL_PHONE;READ_CALL_LOG;WRITE_CALL_LOG;ADD_VOICEMAIL;USE_SIP;PROCESS_OUTGOING_CALLS
  7. SENSORS:BODY_SENSORS
  8. SMS:SEND_SMS;RECEIVE_SMS;READ_SMS;RECEIVE_WAP_PUSH;RECEIVE_MMS
  9. STORAGE:READ_EXTERNAL_STORAGE;WRITE_EXTERNAL_STORAGE

API23检查和请求权限的方法是:checkSelfPermissionrequestPermissions(API23)
流程是:先检查有没有权限,如果有直接调用,如果没有,则请求权限,接下来
论用户同意还是拒绝,activity的onRequestPermissionsResult会被回调来通知结果(通过第三个参数)。
如果用户第一次拒绝权限,下次requestPermissions的时候使用shouldShowRequestPermissionRationale来跟用户解释。


参考:
泡网上的解释:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0830/3387.html





Android 6.0新特性:权限

标签:

原文地址:http://www.cnblogs.com/fruitbolgs/p/5100196.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!