android - Why use GoogleAPIClient to request location updates? -
i noticed it's possible request location updates in (at least) 2 different ways.
using
googleapiclient
:// callback when googleapiclient connected @override public void onconnected(bundle connectionhint) { locationservices.fusedlocationapi.requestlocationupdates( mgoogleapiclient, mlocationrequest, this); }
using
locationmanager
:locationmanager locationmanager = (locationmanager) getactivity(). getsystemservice(context.location_service); locationmanager.requestlocationupdates(locationmanager.gps_provider, 0, 0, locationlistener);
google seems promote method 1
in tutorial "receiving location updates". it's unclear me benefit of method 1
is, because method 2
working fine me (i'm using both methods in 2 different places in app).
the new method location updates use fused location provider in android. best thing fused location provider api you not need worry location updates gives latest , accurate location , updates location after interval or on location change . 1 more thing fused location provider api you don't need think best location provider because automatically choose best 1 suited hardware of android device.
here youtube video in i/o 2013, may provide more details.
Comments
Post a Comment