On Tue, Jul 12, 2011 at 6:59 PM, Ab Caballero <[email protected]> wrote: > I am binding to a service to access GPS data. However I can't access > the data directly because it is local to the LocationListener class. I > have attempted to create a shared preference and access it that way: > > SharedPreferences prefs = > getSharedPreferences(USER_SHARED_PREFERENCES, MODE_WORLD_READABLE); > Editor editor = prefs.edit(); > long latitude = Math.round(loc.getLatitude()); > long longitude = Math.round(loc.getLongitude()); > editor.putLong(USER_LATITUDE, latitude).commit(); > editor.putLong(USER_LONGITUDE, longitude).commit(); > > but the activity seems not to be able to access it and the > documentation seems to indicate that shared preferences can only be > used with activities. Is there a way for me to access this data once > the service is bound?
Call a method on the Binder exposed by the service. That's the only reason you bound to it in the first place -- otherwise, you probably should not be using the binding pattern. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

