google code prettify

2017年1月4日 星期三

[Android BLE] Asking Multiple Permissions for Android SDK6 above

IDE:Android Studio 2.1
Android SDK 6.0 使用BLE時,需要在進入APP時,詢問權限,此範例是一次詢問多種權限。
我承認我是懶豬斌(舉手答右),以下文字轉自
Android Develpers Document for Requesting Permissions at Run Time

On all versions of Android, your app needs to declare both the normal and the dangerous permissions it needs in its app manifest, as described in Declaring Permissions. However, the effect of that declaration is different depending on the system version and your app's target SDK level:

  • If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all
  • If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request.

示意圖如下:


基於安全性變的更嚴謹,所以從原本的一次允許全部權限,改成一個一個允許權限。
半年前寫的GitHub Source Code ,請自行下載服用

IDE:Android Studio 2.1
Android SDK :4.3 ~ 6.0 is Working。

Reference

沒有留言:

張貼留言