Android Question Getting permissions before loading main activity

Kevin Hartin

Active Member
Licensed User
My app is a Tour Guide that uses the following;
SQLite DB in File.DirInternal and initialised in Starter and works fine
GPS that is initialised in Starter and works fine
OSMdroid Offline Map in File.DirRootExternal /osmdroid which on a virgin install fails because the PERMISSION_WRITE_EXTERNAL_STORAGE are not set

Main Activity_Create does the following;
Offline map file is checked to exist and then copied from File.DirAssets as it seems it can only work in that directory
PROBLEM IS IF I CHECK FOR PERMISSION_WRITE_EXTERNAL_STORAGE THE SUB PAUSES AND NEVER FINISHES EXECUTING, BUT GOES DIRECTLY TO Activity_Resume
I then load up all the MapView stuff
ON A VIRGIN INSTALL THE PERMISSION_WRITE_EXTERNAL_STORAGE ARE NOT YET SET SO THE MAP IS NOT FOUND AND THE MAPVIEW DOESNT SHOW ANYTHING
I then set a splash image as visible on top of the map view, which goes away on click

If I exit the app and Force Stop in the Apps list in Setup, then restart the app, everything works fine from that point on.

So, the frustration is how can I delay the loading of the mapview until the permissions are requested and enabled? The new user experience is hopeless and I have had to cancel some more extensive beta testing until I get this sorted.

Thanks,
Kev
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
N A VIRGIN INSTALL THE PERMISSION_WRITE_EXTERNAL_STORAGE ARE NOT YET SET SO THE MAP IS NOT FOUND AND THE MAPVIEW DOESNT SHOW ANYTHING
Please don't write with all capitals. It just makes it less readable.

Why aren't you copying the files to File.DirInternal?

Why are you loading MapView before the permission is received? Where is the relevant code?
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
in one app i used an extra permissions activity, i request all needed permissions and transfer the result into checkboxes.
if all there it automatically continue to the home screen, if not the user must goto home screen by button and he see that some permissions are missing.
the app do what she can do with the given permissions but i not force anything.
 
Upvote 0

Kevin Hartin

Active Member
Licensed User
Please don't write with all capitals. It just makes it less readable.

Why aren't you copying the files to File.DirInternal?

Why are you loading MapView before the permission is received? Where is the relevant code?
Sorry about the ALLCAPS, I was just trying to highlight my comments distinct from my observations.

Anyway, I managed to get it sorted by using my Splash screen Image and its click event to request permissions, copy the map from File.DirAssets, load the Map and finally hide the splash screen. I have Global variables set True or False to determine whether various things need to be done or not.

Cheers,
Kev
 
Upvote 0
Top