【发布时间】:2015-10-22 10:26:03
【问题描述】:
【问题讨论】:
-
我认为它只是在 6.0 中使用。
标签: android location android-location
【问题讨论】:
标签: android location android-location
是的,这很容易做到。请参阅documentation. 下面的代码从文档中复制而来,展示了如何检查用户是否批准或取消了权限请求:
@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;
}
// other 'case' lines to check for other
// permissions this app might request
}
}
【讨论】: