I have a job to determine user location. I can create application class in ApplicationListener. Or I can use the service
location manager location standard = (location manager) this.getSystemService (context.LOCATION_SERVICE); LocationListener Localizer = New LocationListener () {Location change location (location location) {dive.setLongitude (location.getLongitude ()); Dive.setLatitude (location.getLatitude ()); MapHelper.setMapPosition (dive.getLatitude (), dive.getLongitude ()); } Provider enabled on public zero {} public provider on Status Changez (String Provider, Int Status, Bundle Extras) Provider Disenited (String Provider) {}} on Public Zero; LocationManager.requestLocationUpdates (LocationManager.NETWORK_PROVIDER, 0,0, locationListener); LocationManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 0,0, locationListener);
What do I need to use for this task? Service or application class? What are the advantages and disadvantages of the service? What are the advantages and disadvantages of the application class?
You will never use the application, you can use the activity It is more convenient, but can not depend on the next activity, the service requires less boilerplate and less ease of access to data, but it can be used for many activities, which require data.
No comments:
Post a Comment