Request User Permissions
in order to receive from Network_provider or Gps_provider the location of the update, you must pass the declaration access_coarse_location or access_fine_location permission to separate in your Android Request user Permissions in the list, such as:
<manifest ... >
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
...
</manifest>
Without these permissions, your application will have a run-time error when the request location update occurs.
Note: If you are using both Network_provider and Gps_provider, you only need to apply for access_fine_location permissions because it contains the permissions for both location providers. (The access_coarse_location contains only Network_provider permissions.) )
Model that defines the best performance
Location-based applications are now more prevalent, but due to their poor precision, there are a number of ways to get the location of a user's movement, and they want to be able to save power, so getting a user's location is complex. To overcome the barriers to getting a good user position while protecting the battery consumption, you must define a consistent model to specify how the application obtains the user's location. This model contains the opportunity to start and stop listening for updates and to use cached location data.
Process for obtaining a user's location
The following is a typical process flow for acquiring a user's location:
1. launch the application;
2. later, initiate a monitoring of updates to the desired location provider;
3. to maintain a current optimal position assessment by selecting a new location;
4. Stop the monitoring of the location update;
5. Take advantage of the best location for the final assessment.
Figure 1 A visual timeline that demonstrates the location updates that are being monitored in the application, and the timing of these events:
Figure 1. represents the timeline of the window in the application that is used to listen for location updates.
this window model --- during a receive location update, you need to decide when to add location-based services to your application.
Android targeting strategy