Android 权限控制应用程序对敏感资源和数据(摄像头、位置、联系人、存储)的访问。应用程序必须声明权限,对于危险权限,必须在运行时请求它们——保护用户隐私和安全。
为什么权限存在
Apps need user PERMISSION to access sensitive resources/data:
→ protects PRIVACY and security — apps can't silently access your camera, location,
contacts, microphone, etc.
→ the user decides whether to grant access
声明和请求权限
1. DECLARE in AndroidManifest.xml (all permissions the app may use):
<uses-permission android:name="android.permission.CAMERA" />
2. NORMAL permissions (low-risk, e.g. internet) → granted automatically at install
3. DANGEROUS permissions (camera, location, contacts, etc.) → must be REQUESTED at
RUNTIME (the user sees a dialog and grants/denies)
