How can I turn on my phone's GPS in Android?

salisali USMember

Hello,
I am trying to implement read location in my application. I can only get coordinates when GPS is ON by manually enabling my phone's GPS. Is there a code which can enable the GPS some way?

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Its not the responsibility of your APP to decide the user wants to broadcast their location. Maybe they don't want it on for a reason. While there might be a way to do it, don't count on it.. And don't expect any loopholes in security permissions that you find today to still be around next week or next year.

    Better to follow standards and pop up a notice letting the user know they need to turn on location services if they want your app to work.

  • salisali USMember

    Yeah I have implemented turn on location services it only enables the location services and GPS is still OFF.

  • jvckejvcke Member ✭✭

    2 years later :smile:

    Facing similar problem. I'm able to ask the user for location permissions but if the GPS is still off then it doesn't really mean anything.

    When you open the google maps app with the GPS off, the app asks if you want to turn if on for you.
    ~~~~
    Did you find a solution?

  • JoeMankeJoeManke USMember ✭✭✭✭✭
    edited February 27

    How to ask for the user to turn on their GPS:

    https://forums.xamarin.com/discussion/comment/317764#Comment_317764

  • NMackayNMackay GBInsider, University mod

    @jvcke said:

    2 years later :smile:

    Facing similar problem. I'm able to ask the user for location permissions but if the GPS is still off then it doesn't really mean anything.

    When you open the google maps app with the GPS off, the app asks if you want to turn if on for you.
    ~~~~
    Did you find a solution?

    Try and open a new thread, opening old threads doesn't help....although Joe's advice as always looks good!

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    @jvcke

    Solution for... what... exactly?
    How to get around the requirement that the user has to approve being GPS tracked? That's not a problem to be solved. That's personal privacy.

    What... exactly... are you trying to do/solve?

  • jvckejvcke Member ✭✭

    @ClintStLaurent I think @JoeManke just answered my question in the thread he linked to.

    Anyways, my problem is/was:

    I can ask the user if the app can have permission to use the users location in the app. FINE_LOCATION and COARSE_LOCATION etc etc. That works fine.

    It does'nt matter though if the user's phone has it's GPS disabled. So i want to prompt the user for that to.

    Thanks for answering btw.

Sign In or Register to comment.