Android Question [SOLVED] Runtime Permission for gps and sqlLite dir

yfleury

Active Member
Licensed User
I have a crash on start app
B4X:
Logger connected to:  samsung SM-T590
--------- beginning of main
Copying updated assets files (7)
*** Service (starter) Create ***
table créé
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
true
** Activity (main) Resume **
--------- beginning of crash
java.lang.RuntimeException: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzab.zza(Unknown Source:2)
    at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(Unknown Source:12)
    at com.google.android.gms.internal.maps.zzb.onTransact(Unknown Source:12)
    at android.os.Binder.transact(Binder.java:635)
    at fv.b(:com.google.android.gms.dynamite_mapsdynamite@16086045@16.0.86 (040304-237483552):14)
    at com.google.android.gms.maps.internal.bd.a(:com.google.android.gms.dynamite_mapsdynamite@16086045@16.0.86 (040304-237483552):4)
    at com.google.maps.api.android.lib6.impl.bk.run(:com.google.android.gms.dynamite_mapsdynamite@16086045@16.0.86 (040304-237483552):4)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:7002)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at com.google.maps.api.android.lib6.impl.bf.c(:com.google.android.gms.dynamite_mapsdynamite@16086045@16.0.86 (040304-237483552):569)
    at com.google.android.gms.maps.internal.l.a(:com.google.android.gms.dynamite_mapsdynamite@16086045@16.0.86 (040304-237483552):361)
    at fw.onTransact(:com.google.android.gms.dynamite_mapsdynamite@16086045@16.0.86 (040304-237483552):4)
    at android.os.Binder.transact(Binder.java:635)
    at com.google.android.gms.internal.maps.zza.zzb(Unknown Source:20)
    at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled(Unknown Source:109)
    at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(Unknown Source:112)
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:184)
    ... 14 more
So I manage permission like this
B4X:
Sub Activity_Resume
    If Starter.GPS1.GPSEnabled = False Then
        ToastMessageShow("Please enable the GPS device.", True)
        StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
    Else
        Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        If Result Then CallSubDelayed(Starter, "StartGPS")
        Log ("gps on")

    End If

End Sub
For sql directory I set it:
sql.Initialize(File.DirInternal, "routemap.db", True)
I don't know how to solve it
 

yfleury

Active Member
Licensed User
Thanks Erel
My app run well now
I forget to disable myLocation in MapFragment because of a new layout
 
Top