TheDevMan
TheDevMan

Reputation: 5954

Location Service in Android

I am developing an emergency application in Android. I would like to get GPS location or network location by default, even though the Location service is OFF...

I figured out the below code would do whatever I was looking for:

Intent intent=new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);

But most of them on Google are saying it is a bug not recommended type of usage if so what is the best way to get location when location is OFF?

Upvotes: 0

Views: 147

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007584

But most of them on Google are saying it is a bug not recommended type of usage

That particular script-kiddie hack has not worked in years.

what is the best way to get location when location is OFF?

There is no way to get the location when the location service is off, except via crude mechanisms, such as the geo-IP stuff that some Web sites use. Apps are not allowed to access location information when location services are off for privacy reasons. If you determine that location services are off, you are welcome to ask the user to turn them on.

Upvotes: 1

Related Questions