Name
PermissionRequest -- request permission from user (V8.0)
Synopsis
ok = PermissionRequest(perms)
Platforms
Android only

Function
This function can be used to request certain permissions from the user. Due to security reasons, Android apps need first ask for user permission before they will be able to execute certain actions. This function can be used to request such permissions from the user. Android will then show a dialog box in which the user can either accept or decline the permissions. If he declines, PermissionRequest() will return False, otherwise True will be returned.

The permissions you want to request have to be passed in the perms argument. This can be set to one or more of the following permission flags:

#PERMREQ_READEXTERNAL:
If your app has this permission, it will be able to read files from the external storage device. The external storage device can be accessed through the SDCard item in the table returned by GetSystemInfo(). By default, Android apps are not allowed to read from the external storage device.

#PERMREQ_WRITEEXTERNAL:
If your app has this permission, it will be able to write and read files to/from the external storage device. The external storage device can be accessed through the SDCard item in the table returned by GetSystemInfo(). By default, Android apps are not allowed to write to the external storage device. Note that #PERMREQ_WRITEEXTERNAL implies #PERMREQ_READEXTERNAL so you don't have to set #PERMREQ_READEXTERNAL when using this flag.

To ask for multiple permissions at once, simply combine them using the bitwise Or operator.

Note that this function is only needed when compiling stand-alone APKs using the Hollywood APK Compiler. When using the Hollywood Player, the Hollywood Player will automatically request the #PERMREQ_WRITEEXTERNAL permission for you so you don't have to do that manually.

Inputs
perms
one or more permissions to request (see above for possible values)
Results
ok
True if user granted permission, False if he declined them
Example
If PermissionRequest(#PERMREQ_WRITEEXTERNAL)
  t = GetSystemInfo()
  StringToFile("Hello World", FullPath(t.SDCard, "test.txt"))
Else
  NPrint("Sorry, no permission!")
EndIf
The code above tries to get a permission from the user to write to the external storage device. If the user grants this permission, the code will write a file named test.txt to the external storage device.

Show TOC