0

I want to create a app which send users current location when user click on send button . If gps is on than it will send the location, if gps is off then it automatically start the gps and then send location... Manifest permissions is not a problem, problem is that it should not pop up dialogue to start gps when it is off.. Please help me, i really need help..

I want to know that is it possible? If yes then a provide useful link or code or any kind of hint.. Thank you :)

Manish Menaria
  • 23,899
  • 3
  • 21
  • 23
  • 5
    Not possible. There is no way to enable the GPS radio programmatically. You need to prompt the user. If the user doesn't want to enable the GPS radio, they won't enable it. No way to get around it. – Daniel Nugent Jun 11 '15 at 18:09
  • Sad news for me :( thank u so much for reply :) – Manish Menaria Jun 11 '15 at 18:12
  • Better get use to having dialogs showing when you request permissions with android M around the corner – tyczj Jun 11 '15 at 18:12

1 Answers1

1

There are a lot of other threads discussing this, and the general consensus is that it shouldn't be possible, even though on some versions there are exploits that allow it.

However, this doesn't seem to be ethical, since you are violating your users privacy by not allowing them to choose whether or not they want to share their location.

How can I enable or disable the GPS programmatically on Android?

Turning on and off GPS programmatically in android 4.0 and above?

ICS Android enable gps programmatically?

Acapulco
  • 3,373
  • 8
  • 38
  • 51
  • He is going to need to handle the user not wanting to give permission anyway with andoid M – tyczj Jun 11 '15 at 18:14
  • User will click one the button send location, i don't think so this way i am violating user privacy? Thank you for your reply :) – Manish Menaria Jun 11 '15 at 18:15
  • 1
    Maybe I didn't explain myself clearly. I didn't mean to imply that you will be doing this to violate user's privacy, but that this is the reason why it's a hack and not a feature. If Google let developers enable GPS without asking for the user permission, then it's up to the developer to be "ethical" in this regard, and then it's open for abuse to unethical people. That's why it probably won't ever be an official way to do it, except hacks and exploits that will be treated as security bugs and fixed. Sorry for the confusion. – Acapulco Jun 11 '15 at 18:24