Pick up the user's location without using GPS

6

Hello. I'm developing an android application that needs to notify a group of users who are in a certain region. The only way I know of picking up the user's location is by using GPS.

The problem is that enabling / disabling gps requires user approval, which means that you will no longer be able to notify in a particular region.

How can I solve this problem ?, What are the possible techniques useful for this situation?

    
asked by anonymous 11.11.2017 / 17:21

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 for obtaining the location, based on the availability and requirements indicated, uses the most appropriate medium.

If you are using the FusedLocationProviderClient requirements are indicated through of 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 use to get the location are chosen based on the LocationRequest defined. A LocationRequest with a priority of PRIORITY_LOW_POWER may not use GPS if another source is available that guarantees the required accuracy - about 10 km.

So there's nothing you can do. If the user does not allow the GPS to connect the API can not use it. However, the location will still be obtainable by another available medium (if any) but with less precision.

See these questions for more detail.

Note Whatever medium you use the application will always require ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission.

    
11.11.2017 / 18:24