JMB Active Member Licensed User Longtime User Aug 18, 2019 #1 Hi there, I am trying to get the Demo code for the Fused Location Provider to work. I have put my GEO API key in, and I have added Code: Copy AddPermission(android.permission.ACCESS_FINE_LOCATION) to the manifest but I get a java Security Exception telling that my location requires ACCESS_FINE_LOCATION. I am a bit stumped as to how to add this, as I thought adding the permission to the manifest would do it. Can anyone shed some light? Thank you. JMB
Hi there, I am trying to get the Demo code for the Fused Location Provider to work. I have put my GEO API key in, and I have added Code: Copy AddPermission(android.permission.ACCESS_FINE_LOCATION) to the manifest but I get a java Security Exception telling that my location requires ACCESS_FINE_LOCATION. I am a bit stumped as to how to add this, as I thought adding the permission to the manifest would do it. Can anyone shed some light? Thank you. JMB
BillMeyer Well-Known Member Licensed User Longtime User Aug 18, 2019 #2 Have a look here - you need this as well https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/ Keep that fan turning !! Upvote 0
Have a look here - you need this as well https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/ Keep that fan turning !!
E emexes Expert Licensed User Longtime User Aug 19, 2019 #4 The first code block of this post: https://www.b4x.com/android/forum/threads/gps-tutorial.6592/ has example for use of RunTimePermissions specific to GPS. The post is almost a decade old, but still worked ok when I checked it a week ago. Last edited: Aug 20, 2019 Upvote 0
The first code block of this post: https://www.b4x.com/android/forum/threads/gps-tutorial.6592/ has example for use of RunTimePermissions specific to GPS. The post is almost a decade old, but still worked ok when I checked it a week ago.
JMB Active Member Licensed User Longtime User Aug 19, 2019 #5 Thank you, Emexes and Bill - all very useful. I continue to stagger towards success. However, I am a little confused. I have looked at various pieces of code and the tutorial, and I can't figure out why this piece of code doesn't pop up a dialog asking for permission for use of location? It just sits and does nothing. Code: Copy rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION) Wait For Activity_PermissionResult (Permission As String, Result As Boolean) If Result Then Log("Got FINE LOCATION") Else Log("didn't get permission") End If Upvote 0
Thank you, Emexes and Bill - all very useful. I continue to stagger towards success. However, I am a little confused. I have looked at various pieces of code and the tutorial, and I can't figure out why this piece of code doesn't pop up a dialog asking for permission for use of location? It just sits and does nothing. Code: Copy rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION) Wait For Activity_PermissionResult (Permission As String, Result As Boolean) If Result Then Log("Got FINE LOCATION") Else Log("didn't get permission") End If
DonManfred Expert Licensed User Longtime User Aug 19, 2019 #6 Did you added the permission to the manifest too? Best is to upload a sampleproject which shows the issue. Edit to add: and you are targeting sdk 23+? Code: Copy AddManifestText( <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>) Last edited: Aug 19, 2019 Upvote 0
Did you added the permission to the manifest too? Best is to upload a sampleproject which shows the issue. Edit to add: and you are targeting sdk 23+? Code: Copy AddManifestText( <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>)
JMB Active Member Licensed User Longtime User Aug 19, 2019 #8 Ah, thank you Manfred and others. I didn't realise that one had to add the permission to the manifest. Adding that in caused the dialog asking for permission to access location to show. What is rather strange is that I tried some code which Erel put up in the tutorial and that appeared to work without asking for the permission in the manifest Specifically, this was the code that worked without a permission in the manifest: Code: Copy rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE) Wait For Activity_PermissionResult (Permission As String, Result As Boolean) If Result Then Dim pid As PhoneId Log(pid.GetDeviceId) Else Log("didn't get permission") End If When I ran this, it popped the dialog up with no problem, and yet it is listed as a "Dangerous" permission in the same way that Location access is considered "Dangerous". How can one tell which permissions need to be in the Manifest, and which permissions don't? Or should I just put all the permissions that I need in the manifest, along with the rp.CheckAndReqest code? Thanks to all for your help. JMB Upvote 0
Ah, thank you Manfred and others. I didn't realise that one had to add the permission to the manifest. Adding that in caused the dialog asking for permission to access location to show. What is rather strange is that I tried some code which Erel put up in the tutorial and that appeared to work without asking for the permission in the manifest Specifically, this was the code that worked without a permission in the manifest: Code: Copy rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE) Wait For Activity_PermissionResult (Permission As String, Result As Boolean) If Result Then Dim pid As PhoneId Log(pid.GetDeviceId) Else Log("didn't get permission") End If When I ran this, it popped the dialog up with no problem, and yet it is listed as a "Dangerous" permission in the same way that Location access is considered "Dangerous". How can one tell which permissions need to be in the Manifest, and which permissions don't? Or should I just put all the permissions that I need in the manifest, along with the rp.CheckAndReqest code? Thanks to all for your help. JMB
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2019 #9 In most cases the permissions will be added to the manifest automatically by the compiler. Click on Logs tab - List Permissions. It will show you all the permissions that will be added by the compiler and it will mark the dangerous permissions. Upvote 0
In most cases the permissions will be added to the manifest automatically by the compiler. Click on Logs tab - List Permissions. It will show you all the permissions that will be added by the compiler and it will mark the dangerous permissions.