在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
DELPHI安卓定位权限申请 安卓8及以后版本的权限分为静态和动态申请2部分,而之前的安卓版本只需要静态申请权限。 1)静态申请定位权限: 2)动态申请定位权限: uses System.Permissions, {$IFDEF ANDROID} Androidapi.Jni.Os, Androidapi.Helpers, {$ENDIF} ... FPermissionCoarseLocation: string; FPermissionFineLocation: string; ... procedure TMainForm.FormCreate(Sender: TObject); begin {$IFDEF ANDROID} // Note we can alternatively use literal strings: // 'android.permission.ACCESS_COARSE_LOCATION' // 'android.permission.ACCESS_FINE_LOCATION' // according to the documentation: // https://developer.android.com/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION // https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION FPermissionCoarseLocation := JStringToString(TJManifest_permission.JavaClass.ACCESS_COARSE_LOCATION); FPermissionFineLocation := JStringToString(TJManifest_permission.JavaClass.ACCESS_FINE_LOCATION); {$ENDIF} end; procedure TMainForm.Button1Click(Sender: TObject); begin PermissionsService.RequestPermissions([FPermissionCoarseLocation, FPermissionFineLocation], LocationPermissionRequestResult); end; 3)运行效果图: |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论