Android Question Getting permissions before loading main activity

Discussion in 'Android Questions' started by Kevin Hartin, May 22, 2019.

  1. Kevin Hartin

    Kevin Hartin 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
     
  2. Erel

    Erel Administrator Staff 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?
     
    BillMeyer likes this.
  3. MarkusR

    MarkusR Well-Known Member Licensed 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.
     
  4. Kevin Hartin

    Kevin Hartin Member Licensed User

    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice