Jump to content
Sign in to follow this  
Anna Blanca

I cannot get permission for vibrate

Recommended Posts

Hi. I'm trying getting permission from Android in my app, i'm using standart code for this:

procedure TForm1.GetPermission;
begin
if not PermissionsService.IsPermissionGranted(JStringToString(TJManifest_permission.JavaClass.VIBRATE)) then
PermissionsService.RequestPermissions([JStringToString(TJManifest_permission.JavaClass.VIBRATE)],
procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)
begin
if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then
ShowMessage('Access granted')
else
ShowMessage('Access denied');
end);
end;

But that not works. My app not asking permission on the launch this code, it just sending message 'Access denied'. What's wrong and how fix it? Also, when i'm using this code for getting permission WRITE_EXTERNAL_STORAGE, all working right. 

Share this post


Link to post
Just now, Anna Blanca said:

Hi. I'm trying getting permission from Android in my app, i'm using standart code for this:

You do not need to request the VIBRATE permission at runtime. Just enable it in the Uses Permissions section of the Project Options.

Share this post


Link to post
20 minutes ago, Dave Nottage said:

Just enable it in the Uses Permissions section of the Project Options.

When i making it, my app not asking permission. It's just silent and dead.

Edited by Anna Blanca

Share this post


Link to post
Just now, Anna Blanca said:

When i making it, my app not asking permission

When making what? As I said, you do not need to request permission at runtime, just execute the code that does the vibration. If that code is not working, please show your code. 

Share this post


Link to post
17 minutes ago, Dave Nottage said:

When making what? As I said, you do not need to request permission at runtime, just execute the code that does the vibration. If that code is not working, please show your code. 

Oh, thank you, vibrations working. 

But why application not asking permission for vibrate from user? Usually, when you not pushed button for get access, app cant't working.... 

Share this post


Link to post

Yes, that is strange.
I never tried to get a runtime permission for a "normal" permission, but I had expected that the IsPermissionGrant would also work in same way.
Since it is not explicitely forbidden anywhere in the docs, at least I find no rule for that, maybe the best place to logically derive this from is here:

https://source.android.com/docs/core/permissions/runtime_perms?hl=en

 

It states more or less, that the runtime expressios are intended for >= dangerous permissions, 
from this we could logically deduct that "normal" permissions doesn't need (or better doesn't allow) such requests.

 

Negative logic is sometimes confusing ...

 

Edited by Rollo62

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×