Android Question phone location - a question

kisoft

Well-Known Member
Licensed User
Longtime User
HI
Is it possible to turn on the location on the phone with the help of the code?
can only the user enable the location manually?
 
i believe u can only request the location with runtimepermissions and then a os dialog popup if it is disabled.

Code: Copy
Sub Process_Globals
    Dim rp As RuntimePermissions

Code: Copy
Sub Activity_Create(FirstTime As Boolean)
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
        
End Sub

Code: Copy
Sub Activity_PermissionResult(Permission As String, Result As Boolean)

   If Permission = rp.PERMISSION_ACCESS_FINE_LOCATION Then
       CheckBoxGPS.Checked = Result
       If Result = False Then ToastMessageShow("please enable gps + give permissions ...",True)
   End If
  
End Sub
 
Upvote 0
it should be possible by code but this would require once a other permission.
 
Upvote 0
it should be possible by code
i don´t think this is possible.
You probably can send the user to the Settings using an intent. But the user need to enable it.
 
Upvote 0
it seems every change in location settings result in a user dialog, at least for newer os.
can't found a example to start the location service from code without user interaction.

https://developer.android.com/training/location/change-location-settings

https://developer.android.com/reference/android/location/LocationManager

https://www.mytrendin.com/enable-disable-gps-using-locationmanager/

what DonManfred mentioned
Code: Copy
Sub Test
    
    Dim StartIntent As Intent
    StartIntent.Initialize("android.settings.LOCATION_SOURCE_SETTINGS", "")
    StartActivity(StartIntent)
    
End Sub
 
Last edited:
Upvote 0
Back
Top