Did you check if the standard map application manages to display your
location ?

2008/11/4 Amir <[EMAIL PROTECTED]>

>
> Thanks, I'm still having issues, but now I do see the GPS 'icon' as
> turned on when the application is running.  The issue though is that I
> don't get anything on the map through our online site...no longitude
> and latitude, or anything else.
>
> Here's the revised code I'm using:
>
> package org.gw.service;
>
> import android.content.Context;
> import android.location.Location;
> import android.location.LocationManager;
>
> public class LocationService extends AService {
>  LocationManager lm = null;
>  Location loc = null;
>  public int excute() {
>     getDataMap().put(Command, LOCATION);
>
>     if (isOk()) {
>       lm = (LocationManager)
> getContext().getSystemService(Context.LOCATION_SERVICE);
>       loc = lm.getLastKnownLocation("gps");
>      if(loc == null)
>        loc = lm.getLastKnownLocation("network");
>      double sLatitude = loc.getLatitude();
>            double sLongitude = loc.getLongitude();
>         String location = sLatitude+","+sLongitude;
>      //location = "40.738412973944534,-73.98468017578125";
>         getDataMap().put(Des, "OK");
>         getDataMap().put(Value, location);
>      } else {
>         getDataMap().put(Des, "error password!!");
>     }
>      new ServiceClient(this).excute();
>
>     return 0;
>     }
> }
>
>
> On Nov 2, 8:46 am, Akbur <[EMAIL PROTECTED]> wrote:
> > Amir,
> >
> > I've developed a similar app just for kicks (so the wife can keep
> > track of me) ;)
> >
> > I did the following:
> >
> >                         LocationManager lm = (LocationManager)
> > context.getSystemService(Context.LOCATION_SERVICE);
> >
> >                         Location loc = lm.getLastKnownLocation("gps");
> >                         if (loc == null)
> >                         {
> >                                 locType = "Network";
> >                                 loc = lm.getLastKnownLocation("network");
> >                         }
> >
> > In this case if the GPS service does not have a fix or is switched
> > off, the network, though not as accurate as GPS should be active and
> > give you an approximate location.
> >
> > All the best,
> > Akbur
> >
> > On Nov 2, 11:45 am, Guillaume Perrot <[EMAIL PROTECTED]> wrote:
> >
> > > It can take a while to the G1 to init the gps and return a fix.
> > > And you must see the sky for the GPS to work.
> > > Your code and permissions seem correct, try using the network provider
> > > to test (which is faster and work in buildings unlike the GPS).
> > > Make sure GPS location provider is enabled on the phone settings.
> > > You can check your location with the standard map application.
> >
> > > On Nov 2, 5:42 am, C-LIS Keiji Ariyama <[EMAIL PROTECTED]> wrote:
> >
> > > > Hi Amir,
> >
> > > > I had encountered a same situation. But my case is about
> > > > getLastKnownLocation(String) <
> cid:part1.07010905.08080...@c-lis.co.jp<[EMAIL PROTECTED]>
> >
> > > > method on the emulator.
> > > > In that time, I fixed my code below.
> >
> > > > ---- Old ----
> > > > public class TestActivity extends Activity {
> > > >     private void initActivity() {
> > > >         LocationManager locman = (LocationManager) getContext()
> > > >                 .getSystemService(Context.LOCATION_SERVICE);
> > > >     }}
> >
> > > > ---------
> >
> > > > ---- Fixed ----
> > > > public class TestActivity extends Activity {
> > > >     LocationManager locman = null;
> > > >     private void initActivity() {
> > > >         locman = (LocationManager) getContext()
> > > >                 .getSystemService(Context.LOCATION_SERVICE);
> > > >     }}
> >
> > > > ---------
> >
> > > > Sorry. I don't know about G1. Because I have not been having it...
> >
> > > > Keiji,
> >
> > > > Amir wrote:
> > > > > I'm creating a project that allows for my location to be found
> using
> > > > > the android device and communicating with my website as to where my
> > > > > Android device is.  When I download the .apk to my phone the
> following
> > > > > permissions are acquired:
> >
> > > > > Network communication (full)
> > > > > Your location (fine (GPS), coarse (network-based) location)
> >
> > > > > As of now, on the emulator everything works fine and I can find my
> > > > > location (default location on Google Maps), but on the phone the
> > > > > application/device can't find location of the android phone.
> >
> > > > > please help!...below is the code I'm using for the GPS section.
> >
> > > > > - Amir
> >
> > > > > ----
> >
> > > > > package org.gw.service;
> >
> > > > > import android.content.Context;
> > > > > import android.location.Location;
> > > > > import android.location.LocationListener;
> > > > > import android.location.LocationManager;
> > > > > import android.os.Bundle;
> > > > > import android.widget.Toast;
> >
> > > > > public class LocationService extends AService {
> >
> > > > >    public int excute() {
> > > > > getDataMap().put(Command, LOCATION);
> >
> > > > > if (isOk()) {
> >
> > > > >     // // location.
> > > > >     // getDataMap().put(Des, "OK");
> > > > >     // //get location
> > > > >     // getDataMap().put(Value, "100,100");
> > > > >     // String location = "25,121.55";
> > > > >     LocationManager lm = (LocationManager) getContext()
> > > > >      .getSystemService(Context.LOCATION_SERVICE);
> >
> > > > >     LocationListener locationListener = new
> GWLocationListener(this);
> > > > >     lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
> > > > >      locationListener);
> >
> > > > > } else {
> > > > >     getDataMap().put(Des, "error password!!");
> > > > > }
> >
> > > > > return 0;
> > > > >    }
> >
> > > > >    private class GWLocationListener implements LocationListener {
> > > > > private LocationService service;
> > > > > public GWLocationListener(LocationService service) {
> > > > >     this.service=service;
> > > > > }
> >
> > > > > @Override
> > > > > public void onLocationChanged(Location loc) {
> > > > >     if (loc != null) {
> > > > >  String location = loc.getLatitude()+","+loc.getLongitude();
> > > > >  service.getDataMap().put(Value, location);
> > > > >   getDataMap().put(Des, "OK");
> > > > >  new ServiceClient(service).excute();
> > > > >     }
> > > > >     else
> > > > >     {
> >
> > > > >  getDataMap().put(Des, "Location fail!");
> > > > >  new ServiceClient(service).excute();
> > > > >     }
> > > > > }
> >
> > > > > @Override
> > > > > public void onProviderDisabled(String provider) {
> > > > >    return;
> > > > > }
> >
> > > > > @Override
> > > > > public void onProviderEnabled(String provider) {
> > > > >     return;
> > > > > }
> >
> > > > > @Override
> > > > > public void onStatusChanged(String provider, int status, Bundle
> > > > > extras) {
> > > > >     return;
> > > > > }
> > > > >    }
> > > > > }
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to