Android location problem

Source: Internet
Author: User

============ Problem Description ============


The Great God of you:
How to integrate GPS, base station positioning, WiFi positioning effectively integrated, so that the system based on the network to make effective positioning method, thank you

============ Solution 1============


Upstairs, that's right, implement the Locationlistener onlocationchanged,onproviderdisabled,onproviderenabled,onstatuschanged interface.

============ Solution 2============


But base station location and WiFi location (IP) or need a third-party package depends on Ah, otherwise you will have to set up the base station database, get all the base station data, IP is the same, can be resolved.

============ Solution 3============


So you've registered two provider, Gps_provider & Network_provider. But there are still problems. GPS accuracy is high and reliable, but the stability is poor, network mode is fast but unreliable, because the location depends on the agent you use and other reasons. As for your original intention "the system according to the network environment to make an effective positioning method", this can do an interactive choice for users to choose if the GPS can't get location using network location, if both methods have location information, and error more than a certain degree, let the user decide which to use.
Reference 9 Floor Tomkan's reply:
Private Android.location.LocationManager Mlocationmanager;
Locationlistener [] mlocationlisteners = new locationlistener[] {
New Locationlistener (Android.location.LocationManager.GPS_PROVIDER),
New Locationlistener (Android.location.LocationManager.NETWORK_PROVIDER)
};
if (Mlocationmanager = = null) {
Mlocationmanager = (Android.location.LocationManager)
Mcontext.getsystemservice (Context.location_service);
}
if (Mlocationmanager! = null) {
try {
Mlocationmanager.requestlocationupdates (
Android.location.LocationManager.NETWORK_PROVIDER,
1000,
0F,
MLOCATIONLISTENERS[1]);
} catch (SecurityException ex) {
LOG.I (TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
LOG.D (TAG, "provider does not exist" + ex.getmessage ());
}
try {
Mlocationmanager.requestlocationupdates (
Android.location.LocationManager.GPS_PROVIDER,
1000,
0F,
Mlocationlisteners[0]);

} catch (SecurityException ex) {
LOG.I (TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
LOG.D (TAG, "provider does not exist" + ex.getmessage ());
}
LOG.D (TAG, "startreceivinglocationupdates");
}

Android location problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.