• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Asset - Extension Android Permissions extension updated

W

Wraithious

Guest
Android Permissions lets you set permissions at runtime for your Android games!!
Get it now for free on the marketplace!!
Android Permissions Extension

As you may be aware, Android operating systems 6.0 and higher now check for permissions at run time, and it is now up to us the developers to handle this. I have made this extension to do that. there are 25 permissions Android lists as 'Dangerous Permissions' and so there are 25 functions in this extension available for you to use and each function has a request permission and a check permission so there are actually 50 functions total. Most apps only need 1 or 2 dangerous permissions so you'd most likly only need to use 2 - 4 of them but to cover every situation I have included ALL OF THEM for you. here is the list of the dangerous permissions and the related functions in the extension to handle them in this order - permission name, check permission name, get permission function name:
READ_CALENDAR - ChkRcal(); - readCal();
WRITE_CALENDAR - ChkWcal(); - writeCal();
CAMERA - ChkCam(); - Cam();
READ_CONTACTS - ChkCon(); - ReadCon();
WRITE_CONTACTS - ChkWCon(); - WriteCon();
GET_ACCOUNTS - ChkAcct(); - ReadAcct();
ACCESS_FINE_LOCATION - ChkFineLoc(); - ReadFineLoc();
ACCESS_COARSE_LOCATION - ChkCoarseLoc(); - ReadCoarseLoc();
RECORD_AUDIO - ChkAudio(); - RecAudio();
READ_PHONE_STATE - ChkPhState(); - ReadPhState();
CALL_PHONE - ChkCallPhone(); - CallPhone();
READ_CALL_LOG - ChkCallLog(); - ReadCallLog();
WRITE_CALL_LOG - ChkWriteCallLog(); - WriteCallLog();
ADD_VOICEMAIL - ChkVmail(); - AddVmail();
USE_SIP - ChkSip(); - UseSip();
PROCESS_OUTGOING_CALLS - ChkProsOutCal(); - ProsOutCal();
BODY_SENSORS - ChkBodySens(); - BodySens();
SEND_SMS - ChkSendSms(); - SendSms();
RECEIVE_SMS - ChkRecvSms(); - RecvSms();
READ_SMS - ChkReadSms(); - ReadSms();
RECEIVE_WAP_PUSH - ChkRecvPush(); - RecvPush();
RECEIVE_MMS - ChkRecvMms(); - RecvMms();
READ_EXTERNAL_STORAGE - ChkReadExtStor(); - ReadExtStor();
WRITE_EXTERNAL_STORAGE - ChkWriteExtStor(); - WriteExtStor();
MOUNT_UNMOUNT_FILESYSTEMS - ChkMountFile(); - MountFile(); // This permission does not need to be asked for, instead,
inject it into the manifest by double clicking the extension and selecting the android tab, then paste in this permission with the android.permissions. prefix. Then you must ask for write permission to activate it. This is because write permission grants any manifest defined permissions related to read/writing.

Don't forget to check the permissions box(s) in the global game settings for the permissions you want to use, and if your permission isn't listed in the global game settings you need to add it in the Android form by right clicking the extension in the resource tree and selecting properties which brings up the edit extensions form, in here click the android tab and click the add button to type in your permission with the format: android.permission.PERMISSION_NAME (substitute PERMISSION_NAME with the actual name of the permission) This will inject the permission into the android manifest and this extension does the task of implementing the job of asking the user to allow the permission.
To use the extension in your project you would put a code similar to this in the create event of the first instance in the first room of your game:

//Let's say you want to use the permission WRITE_EXTERNAL_STORAGE
global.permissions=0;
if ChkWriteExtStor()==0//If the permission has not been granted
{
WriteExtStor();//Ask the user for the permission
}
else
{
global.permissions=1;//If the game has been run before and we got the permission execute related code
}
//If you need multiple permissions change the global variable into an array and repeat the above process for each permission you need.

Then in an alarm event check again for the permission so that it will take effect on the first run, otherwise the user will have to close and reopen the app to use the permission's functionality, so just do something like this in the first instance's alarm event set to 1:

if ChkWriteExtStor()==1 global.permissions=1;

So if the user ok's the permission you can use global.permissions anywhere in your game that requires that permission to check if you can perform the task, or alternatly if the permission is denied you can use the global.permissions variable to show the user a message asking them to enable it in settings if they want to use your app's functionality that requires that permission. NOTE - Do a clean, full build install of your app to test, to be specific, You must do a final build to test it by using the create executable for target button, uninstall the test project if you've previously test run it with the yoyo runner, then install your app on your android device to test. (denying permissions in test mode denies the runner access to your phone and will crash your game)

This info can also be found on the Android Permissions home page on my website:
Android Permissions home page

A demo apk can be downloaded here:
Android Permissions APK

Get it now for free on the marketplace!!
Android Permissions Extension

scrs1.png scrs2.png
 
Last edited by a moderator:
W

Wraithious

Guest
UPDATE 1026/2017​
You may be aware that now Google Play requires any games or apps submitted to the play store to show a reason for requesting dangerous permissions that access personal information, so there is now an extra function for that in my extension, and as a bonus, it also allows several permissions to be asked for at once.
So the new function is:
ShowReasoning( String "PERMISSION_NAME1 PERMISSION_NAME2 etc.. but must be all capital letters" ,String "The reason");
Separate each permission with a space.
A dialog box will come up with the list of permissions and the reason you need them, then seperate dialog boxes will be shown to confirm or deny the permissions.
This would be an example of how to ask for permission AND show a reason OR ask for multiple permissions at once:
Code:
global.permissions=0;
if (ChkWriteExtStor()==0 || ChkAudio()==0) //If the permission has not been granted
{
ShowReasoning("WRITE_EXTERNAL_STORAGE RECORD_AUDIO", "To use this app.");
}
 else
{
global.permissions=1;//If the game has been run before and we got the permission execute related code
}
I have left all the old functions there also in the case that you don't want (or need) to give a reason. I also left the previous version of the extension on the market place in case you want to roll back to it, the reason for that is to get the dialog box to work your project must have a minimum sdk of 11 or higher, the previous version allows sdk version 9 and higher.

This info can also be found on the Android Permissions home page on my website:
Android Permissions home page

Get it now FOR FREE on the marketplace!!
Android Permissions Extension
 
Last edited by a moderator:
Top