Tuesday, 15 September 2015

gps - Android LocationManager - cannot resolve method -



gps - Android LocationManager - cannot resolve method -

i'm trying location manager work in activity in android app keeps giving me error "cannot resolve method requestlocationupdates"

i'm putting code in oncreate (found other examples):

// acquire reference scheme location manager locationmanager locationmanager = (locationmanager) this.getsystemservice(context.location_service); // define listener responds location updates locationlistener locationlistener = new locationlistener() { public void onlocationchanged(location location) { // called when new location found network location provider. makeuseofnewlocation(location); } public void onstatuschanged(string provider, int status, bundle extras) {} public void onproviderenabled(string provider) {} public void onproviderdisabled(string provider) {} }; // register listener location manager receive location updates locationmanager.requestlocationupdates(locationmanager.network_provider, 0, 0, locationlistener);

i want utilize own "onlocationchanged" method update map users location, can't figure out why i'm getting error.

any ideas why i'm getting error?

is there improve more modern way implement location updates?

thanks!

i recommend new fusedlocationproviderapi part of google play services. docs:

the google location services api, part of google play services, provides more powerful, high-level framework automatically handles location providers, user movement, , location accuracy. handles location update scheduling based on powerfulness consumption parameters provide. in cases, you'll improve battery performance, more appropriate accuracy, using location services api.

android gps locationmanager locationlistener

No comments:

Post a Comment