Custom permission messages

44 views
Skip to first unread message

Hannah R

unread,
Jul 6, 2021, 3:03:15 PM7/6/21
to CodenameOne Discussions
How to add custom permission messages? 

I followed this blog (https://www.codenameone.com/blog/tip-intercept-incoming-sms-on-android.html) and added Display.getInstance().setProperty("android.permission.ACCESS_COARSE_LOCATION", "We need access to your location"); into my init() method, but nothing happened. I still get default dialogs when the permission is requested.

Thank you. 

Hannah R

unread,
Jul 6, 2021, 3:05:07 PM7/6/21
to CodenameOne Discussions

Shai Almog

unread,
Jul 6, 2021, 10:47:06 PM7/6/21
to CodenameOne Discussions
I don't see that permission in code. I see fine location and android.permission.ACCESS_BACKGROUND_LOCATION but not COARSE. I'll have to check.

Hannah R

unread,
Jul 7, 2021, 9:12:09 AM7/7/21
to CodenameOne Discussions
Thank you. 
I tried with the  ACCESS_BACKGROUND_LOCATION too, same result - no message is shown. 

Am I missing something? 

Shai Almog

unread,
Jul 7, 2021, 10:02:36 PM7/7/21
to CodenameOne Discussions
What about android.permission.ACCESS_FINE_LOCATION ?
Do you have the exact text of the message you're getting? I can search the source code for it and see where it's coming from.

Hannah R

unread,
Jul 8, 2021, 4:29:06 PM7/8/21
to CodenameOne Discussions
I can see I get the custom notification after I deny the permission and then trigger the location requirement again. For some reason I was convinced that this message should appear when the Location called, not only when the permission is denied. 
This works with android.permission.ACCESS_FINE_LOCATION.
However,  android.permission.ACCESS_BACKGROUND_LOCATION still doesn't show custom messages - after you denied it, and then tried to use Location again, it's asking default "Allow background location".

I created a simple dialog for the moment when the permission will be asked. 

Shai Almog

unread,
Jul 8, 2021, 11:13:12 PM7/8/21
to CodenameOne Discussions
If you can produce a test case for this please file an issue and we'll try to look into it.
Reply all
Reply to author
Forward
0 new messages