Get user location without using GPS

Asked

Viewed 611 times

6

Hello. I’m developing an application on android that you need to notify a group of users who are in a certain region. The only way I know how to get the user’s location is by using GPS.

The problem is that to enable/disable the gps it is necessary the approval of the user, with this, it will no longer be possible to notify in a certain region.

How can I solve this problem? , what are the possible techniques useful to this situation?

1 answer

5


GPS is not the only way to get the user’s location. It can be obtained by WI-FI or mobile network (antenna triangulation). However, its accuracy may be low for what you want.

The API to get the location, depending on the availability and requirements indicated, uses the most appropriate medium.

If you are using Fusedlocationproviderclient requirements are indicated via a Locationrequest object:

mLocationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setInterval(10 * 1000)        // 10 seconds, in milliseconds
                .setFastestInterval(1 * 1000); // 1 second, in milliseconds 

The means or means to be used to obtain the location are chosen according to the Locationrequest set. A Locationrequest with a PRIORITY_LOW_POWER priority may not use GPS if another source is available that guarantees the required accuracy - about 10 Km.

So there is nothing you can do. If the user does not allow the GPS to turn on the API can not use it.
However the location will still be obtainable by another available means (if any) but with less precision.

See these questions for more detail.

Note Whatever the means used the application will always need permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.