13. App Permissions?
“If an app supports the new
permissions model, it can still be
installed and run on devices running
older versions of Android, using the old
permissions model on those devices.“
15. App Permissions?
“On devices running the M Developer Preview, a user can turn off permissions for any app
(including legacy apps) from the app's Settings screen. If a user turns off permissions for
a legacy app, the system silently disables the appropriate functionality. When the app
attempts to perform an operation that requires that permission, the operation will not
necessarily cause an exception. Instead, it might return an empty data set, signal an
error, or otherwise exhibit unexpected behavior. For example, if you query a calendar
without permission, the method returns an empty data set.“
Forwards and backwards compatibility
16. App Permissions?
“On devices running the M Developer Preview, a user can turn off permissions for any app
(including legacy apps) from the app's Settings screen. If a user turns off permissions for
a legacy app, the system silently disables the appropriate functionality. When the app
attempts to perform an operation that requires that permission, the operation will not
necessarily cause an exception. Instead, it might return an empty data set, signal an
error, or otherwise exhibit unexpected behavior. For example, if you query a calendar
without permission, the method returns an empty data set.“
Forwards and backwards compatibility
⻑⾧長い…
17. App Permissions?
“On devices running the M Developer Preview, a user can turn off permissions for any app
(including legacy apps) from the app's Settings screen. If a user turns off permissions for
a legacy app, the system silently disables the appropriate functionality. When the app
attempts to perform an operation that requires that permission, the operation will not
necessarily cause an exception. Instead, it might return an empty data set, signal an
error, or otherwise exhibit unexpected behavior. For example, if you query a calendar
without permission, the method returns an empty data set.“
Forwards and backwards compatibility
App Permissionsに対応してないアプリで権限をOFFした時の話。
例例外起きない。
空データ返ってくる。
32. public abstract class PermissionUtil {
/**
* Returns true if the Activity has access to all given permissions.
* Always returns true on platforms below M.
*
* @see Activity#checkSelfPermission(String)
*/
public static boolean hasSelfPermission(Activity activity, String[] permissions) {
if (!isMNC()) {
return true;
}
for (String permission : permissions) {
if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
return true;
}
public static boolean isMNC() {
/*
TODO: In the Android M Preview release, checking if the platform is M is done through
the codename, not the version code. Once the API has been finalised, the following check
should be used: */
// return Build.VERSION.SDK_INT == Build.VERSION_CODES.MNC
return "MNC".equals(Build.VERSION.CODENAME);
}
}
https://github.com/googlesamples/android-RuntimePermissions
Sample CodeはUtilクラス作ってる