Android Question Turn on GPS

Discussion in 'Android Questions' started by Devv, Oct 1, 2014.

Similar threads

B4A Tutorial GPS tutorial
B4A Question GPS when display turn off
B4A Question Turn on GPS
B4A Question how to turn on GPS with B4a
B4A Question Turn GPS On and Off
  1. Devv

    Devv Active Member Licensed User

  2. Erel

    Erel Administrator Staff Member Licensed User

    This will only work if the settings widget was added. If this is relevant for you then I can help you write this code.
     
    Devv likes this.
  3. Devv

    Devv Active Member Licensed User

    You mean the notification drawer widget that comes with Samsung devices ?
    [​IMG]


    if you could write a library that could enable GPS on devices that uses this widget without user interaction that will be great ...
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    This is the relevant code:
    Code:
    Sub TurnGPSOn
       
    Dim i As Intent
       i.Initialize(
    """3")
       i.SetComponent(
    "com.android.settings/.widget.SettingsAppWidgetProvider")
       i.AddCategory(
    "android.intent.category.ALTERNATIVE")
       
    Dim p As Phone
       p.SendBroadcastIntent(i)
    End Sub
    It doesn't work on Android 4.4. You will see a message in the unfiltered logs about a permission problem.
     
  5. Harris

    Harris Well-Known Member Licensed User

    This has always been a problem.
    If the user chooses NOT to turn on GPS, or I cannot force it on, then the data I collect is invalid - since US government rules demand lat/lon values with each record created.

    Enabling GPS makes it available for all apps (I assume) - even the ones your kids don't want enabled for tracking them.
    I think, as developers, we need an APP ONLY permission - where we need access to GPS. All other apps would have to ask, demand, register the same permission. Google would have to figure that one out...

    The only alternative now, if GPS isn't enabled, is to close the app, or keep demanding that GPS be enabled... Both options stall data collection.
     
  6. Devv

    Devv Active Member Licensed User

    i tried this on samsung grand and s3 both less than 4.4 without any success
     
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