Permissions not asked for on Initialize

955 views
Skip to first unread message
Assigned to ewpa...@gmail.com by chrisw...@gmail.com

Mick Gallagher

unread,
Apr 17, 2019, 11:16:56 AM4/17/19
to MIT App Inventor Forum
Hi, The App i am developing requires a number of permissions to be asked for.
I have a location sensor which asks for permission on initialize. That works fine.
I also have Taifuns Telephony manager which i need to work on initialize to get DeviceId.
The App will only ask for the Location sensor permission on start up.
i can access DeviceId elsewhere in the App but need it on initialize. Can anyone help.
Thanks

Taifun

unread,
Apr 17, 2019, 3:38:16 PM4/17/19
to MIT App Inventor Forum
use the AskForPermission block form the Screen drawer
the telephony manager extension asks for required permissions on first use of a method

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Mick Gallagher

unread,
Apr 18, 2019, 1:47:10 AM4/18/19
to MIT App Inventor Forum
Hi Taifun,
The permissions block works fine in my App and returns the IMEI number successfully. It will work anywhere in my App but will not ask for permission where I need it, on Initialze. The location permission is the only one asked for on Initialize.

Taifun

unread,
Apr 18, 2019, 12:10:58 PM4/18/19
to MIT App Inventor Forum
but will not ask for  permission where I need it, on Initialze.
as already said, use the AskPermission block from the Screen drawer and get the IMEI after that permission has been granted

ABG

unread,
Apr 18, 2019, 5:19:35 PM4/18/19
to MIT App Inventor Forum

Mick Gallagher

unread,
Apr 26, 2019, 4:39:59 AM4/26/19
to MIT App Inventor Forum
Hi,
Yes I realise that the blocks should be on screen Initialise and that is where I have been trying to use them but when the app starts it will only ask for location permissions.
I am using this app on a motorola g5 plus
Android 7.
However it works perfectly on a Samsung galaxy j3 Android 5.1.1
Is there any work around for this.
I need it to work on Initialize.
Thanks for your help

Taifun

unread,
Apr 26, 2019, 1:49:41 PM4/26/19
to MIT App Inventor Forum
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

BodyMindPower

unread,
Apr 26, 2019, 6:12:16 PM4/26/19
to MIT App Inventor Forum
Permissions for API < 23 (Galaxy j3 Android 5.1.1) are required (granted) at install-time and since API >= 23 at runtime. As Taifun said, we need to see the relevant blocks ...

Anke

Mick Gallagher

unread,
Apr 27, 2019, 3:28:24 AM4/27/19
to MIT App Inventor Forum
Hi,
Rather than putting my blocks on here and maybe making the problem more confusing I hopefully have simplified and made clearer the problem.
In my app I have telephony manager to get the IMEI number of the phone.
I also have a location sensor.
So I used Taifuns Telephony manager example app to highlight the problem.
His app works fine and asks for permission on initialize.
However if I add location sensor to the app it will only ask for location permission on initialize.
If the app is closed then opened again, it will ask for READ_PHONE_STATE.
Hope this helps in illustrating my problem

Chris Ward

unread,
Apr 27, 2019, 6:00:26 AM4/27/19
to MIT App Inventor Forum
Hello Mick

The premise is that a picture paints a thousand words :)  If your doctor asks to see your arm, do you only show him/her a written description of it?

What you could do is make a working code snippet (seperate Project) that demonstrates the issue.


BodyMindPower

unread,
Apr 27, 2019, 7:40:06 AM4/27/19
to MIT App Inventor Forum
Apparently, it is not possible to request READ_PHONE_STATE or CALL_PHONE at the same time with another permission on Screen.Initialize (especially if the location sensor is used). So, you have to reopen the app to get this request or to ask for permission by a button or something else. See attached aia to play around with it ...


Also Taifun's advice (example) https://puravidaapps.com/telephonymanager.php does not work in this case.
So, if the location sensor is called on Screen.Initialize, the other permissions have to be requested later via buttons (or something else).


Anke

Mick Gallagher

unread,
Apr 27, 2019, 7:46:26 AM4/27/19
to MIT App Inventor Forum
Hi Chris,
In most cases I would agree with you but chose the simpler method on this occasion

Mick Gallagher

unread,
Apr 27, 2019, 7:54:26 AM4/27/19
to MIT App Inventor Forum
Thanks for your information.
It clears up a lot of questions.
I have had to change the way my app works.
I have already gone down the route of using a button to trigger the permission.
It works well. It would have been nice if it was on Initialize but at the end of the day I still get the same result
Thanks all

Chris Ward

unread,
Apr 27, 2019, 7:55:16 AM4/27/19
to MIT App Inventor Forum
Anke, could the "something else" be a Clock Timer enabled on Screen Initialization?

BodyMindPower

unread,
Apr 27, 2019, 8:14:54 AM4/27/19
to MIT App Inventor Forum
Hi Chris,

yes, I had already thought about that. But the timer would need to know when the permission was granted to request another permission ... (when to enable the timer?).
Also this does not seem to work:

Anke

Chris Ward

unread,
Apr 27, 2019, 8:22:51 AM4/27/19
to MIT App Inventor Forum
I think it's possible that this scenario was overlooked at the time the blocks were introduced (they had to be produced in a hurry).

Assigning to Evan, only he knows really.

BodyMindPower

unread,
Apr 27, 2019, 11:30:12 AM4/27/19
to MIT App Inventor Forum
on the other AI clones this works without any issues ...
Reply all
Reply to author
Forward
0 new messages