Adjust the mode for saving battery power and data exchange
When you test your application, you may find that in order to provide good location and performance, you may need to adjust the mode. The following are some of the things that may change when both of them seek a good balance.
Reduce window size
Using a small window to allow listening for location updates means less interaction with GPS and network location servers, thus extending the battery life cycle. However, it also allows you to select the best estimation result from a few locations.
Set a low update frequency for the location provider
Reducing the display frequency of location updates in the window can also improve battery utilization efficiency, but may affect accuracy. The trade-off between this value depends on how to use your application. Increase the value of parameters in the requestlocationupdates () method to reduce the update frequency. This parameter value specifies the update interval and minimum distance.
Restrict the use of a group of providers
Depending on the environment or expected precision level used by your application, you can choose to use only the network location provider or GPS, interacting with only one of the location services will improve the utilization of battery power and reduce the location accuracy.
Common application scenarios
There are many reasons you want to get the user location in the application. In the following scenarios, you can use user locations to enrich your applications. Each scenario also describes the timing of starting and starting position monitoring to get a good position and save battery power.
Mark the location of the content created by the user
You may want to create an application that marks the location where the user-created content is located, this allows users to share their local experience, send restaurant introductions, or record content that enhances their current location. Demonstrate how this requirement interacts with the location Server:
Figure 2. Timeline indicates the window in which the user obtains the location and the time when the user stops listening at the current location.
Here we use the same expression pattern as the previous article "How To Get user location in code (figure 1. To get the best location accuracy, you may choose to listen for location updates when the user starts to create content or when the application starts, and then when the user completes content Sending or recording, stop listening. You need to consider how long it takes to create a task such as content and determine whether to allow effective collection of location estimates during this period.
Help Users determine their locations
You may want to create an application that tries to provide orientation selection for users. For example, you can provide a list of nearby restaurants, stores, and entertainment venues based on your location.
To achieve this process, you may have to make the following options:
1.
Reschedule the suggestions when obtaining the new best estimation location;
2. if stability is recommended, stop updating the listening location.
This mode is demonstrated:
Figure 3. Timeline indicates the window for dynamically updating data when the user location is updated.