Tuesday, July 27, 2010

[android-developers] Re: LocationManager/Listener, use gps data

just implement the LocationListener interface methods with the action
you want to perform (e.g. for every location change update your
application view) and instantiate the GeoDataGateway in your Activity.

On Jul 25, 11:31 pm, ArtworkAD <artjomzabe...@googlemail.com> wrote:
> Hi all,
>
> I am working on a gps gateway to provide my application with gps data.
> so I have set up a class:
>
> import android.location.Location;
> import android.location.LocationListener;
> import android.location.LocationManager;
> import android.os.Bundle;
>
> public class GeoDataGateway{
>
>         private LocationManager lm = null;
>
>         public GeoDataGateway(){
>
>         }
>
>         public void setLocationManager(LocationManager lmp){
>                 this.lm = lmp;
>         }
>
>         public void startLocationService(){
>                 if(this.lm != null){
>                         this.lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
> new UpdateHandler());
>                 }
>         }
>
>         public class UpdateHandler implements LocationListener{
>
>                 public void onLocationChanged(Location arg0) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>                 public void onProviderDisabled(String provider) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>                 public void onProviderEnabled(String provider) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>                 public void onStatusChanged(String provider, int status, Bundle
> extras) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>         }
>
> }
>
> now everytime gps location changes the method onLocationChanged is
> called and from arg0 I can resolve the lat and lng values for the
> location.
> My problem is that I can not imagine how to bring this location data
> to the core of my application.the process of getting the location of
> the user should run asynchronous to the main application. however my
> first idea would be to add a attribute to the GeoDataGateway for each
> lat and lng. these will be set by the UpdateHandler and via a getLng()
> method it shouöd be easy to get the data!?
>
> please help

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment