[android-beginners] Re: GPS Programming...

2009-09-08 Thread Xster

The example shows only gets the last known location. I need to write a
program that actively tracks the user (it's supposed to keep up with a
car). The GPS works fine in Google Maps

On Sep 8, 1:35 pm, Xster x...@xiao-yu.com wrote:
 Hi,

 The permissions and the settings are correct. I think it crashes if it
 isn't.

 I changed my function a bit such that the update request has a minimum
 delay of 10 seconds and 10 meters. But I still get no updates. I can
 get the last known location from the location manager so I figured
 that works. Just the LocationListener's methods never gets called
 somehow...

 On Sep 7, 10:44 am, The Bear bernard.mcca...@googlemail.com wrote:



  Make sure you add the line
  permission android:name=android.permission.ACCESS_FINE_LOCATION/
  uses-permission
  to your AndroidManifest.xml file and you have enabled GPS satellites
  on your handset (won't work otherwise).

  Then try this:

  public class GPSTest extends Activity {
          private TextView text;
      private LocationManager manager;
      private LocationListener listener;

      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          text = (TextView)findViewById(R.id.Text);

          manager = (LocationManager) getSystemService
  (Context.LOCATION_SERVICE);
          Location myLocation = manager.getLastKnownLocation(gps);

          text.setText((Lat:  + myLocation.getLatitude()
                          + \nLLong:  + myLocation.getLongitude()));

          listener = new MyLocationListener();
          manager.requestLocationUpdates(gps ,1L, 10.0f,
  listener);
      }

      private class MyLocationListener implements LocationListener{

          public void onLocationChanged(Location location) {
                  // TODO Auto-generated method stub
                  if (location != null){
                          text.setText((Lat:  + location.getLatitude()
                                  + \nLLong:  + location.getLongitude()));
                  }
          }

          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
          }
      }

  }

  On Sep 4, 8:49 am, Xster x...@xiao-yu.com wrote:

   Hi,

   I'm trying to start a GPS program and I'm just trying out the first
   step to display coordinates as they change.

   I followedhttp://www.devx.com/wireless/Article/39239andusedthe
   LocationManager and LocationListener classes.

   Code:
   public class GPSTest extends Activity {
       /** Called when the activity is first created. */

           private TextView text;
           private LocationManager manager;
           private LocationListener listener;

       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);

           text = (TextView) findViewById(R.id.Text);

           manager = (LocationManager) getSystemService
   (Context.LOCATION_SERVICE);
           listener = new MyLocationListener();
           manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
   0, 0, listener);
       }

       private class MyLocationListener implements LocationListener{

                   public void onLocationChanged(Location location) {
                           // TODO Auto-generated method stub
                           if (location != null){
                                   text.setText(text.getText() + \n + 
   location.getLatitude() + , 
   + location.getLongitude() +  -  + location.getAccuracy());
                           }
                   }

                   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

                   }

       }

   }

   However, once I run the code on the phone, the GPS icon is seen
   flashing but nothing happens. The method onLocationChanged is never
   reached (according to breakpoints). What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, 

[android-beginners] Re: GPS Programming...

2009-09-08 Thread Xster

Hi,

It turns out that the code was fine, it was just the satellite that
was wildly unreliable. I realised when I implemented the subclass'
onStatusChanged. It was on temporarily unavailable for a long time.

I also realised that given my requestLocationUpdate parameters (5
seconds, 10 meters (I am trying to keep up with a car)), the readings
tend to come in in bursts. Ie, nothing for 1-2 minutes then 5 readings
in 5 seconds. Google's API makes no attempts to correct the reading
given previous data sets right? A kalman filter of some sort. Do we
have control over how the API attempts to get the most accurate
reading? Ie, disable the location by wifi hotspot stuff?



On Sep 8, 1:46 pm, Xster x...@xiao-yu.com wrote:
 The example shows only gets the last known location. I need to write a
 program that actively tracks the user (it's supposed to keep up with a
 car). The GPS works fine in Google Maps

 On Sep 8, 1:35 pm, Xster x...@xiao-yu.com wrote:



  Hi,

  The permissions and the settings are correct. I think it crashes if it
  isn't.

  I changed my function a bit such that the update request has a minimum
  delay of 10 seconds and 10 meters. But I still get no updates. I can
  get the last known location from the location manager so I figured
  that works. Just the LocationListener's methods never gets called
  somehow...

  On Sep 7, 10:44 am, The Bear bernard.mcca...@googlemail.com wrote:

   Make sure you add the line
   permission android:name=android.permission.ACCESS_FINE_LOCATION/
   uses-permission
   to your AndroidManifest.xml file and you have enabled GPS satellites
   on your handset (won't work otherwise).

   Then try this:

   public class GPSTest extends Activity {
           private TextView text;
       private LocationManager manager;
       private LocationListener listener;

       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);

           text = (TextView)findViewById(R.id.Text);

           manager = (LocationManager) getSystemService
   (Context.LOCATION_SERVICE);
           Location myLocation = manager.getLastKnownLocation(gps);

           text.setText((Lat:  + myLocation.getLatitude()
                           + \nLLong:  + myLocation.getLongitude()));

           listener = new MyLocationListener();
           manager.requestLocationUpdates(gps ,1L, 10.0f,
   listener);
       }

       private class MyLocationListener implements LocationListener{

           public void onLocationChanged(Location location) {
                   // TODO Auto-generated method stub
                   if (location != null){
                           text.setText((Lat:  + location.getLatitude()
                                   + \nLLong:  + location.getLongitude()));
                   }
           }

           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
           }
       }

   }

   On Sep 4, 8:49 am, Xster x...@xiao-yu.com wrote:

Hi,

I'm trying to start a GPS program and I'm just trying out the first
step to display coordinates as they change.

I followedhttp://www.devx.com/wireless/Article/39239andusedthe
LocationManager and LocationListener classes.

Code:
public class GPSTest extends Activity {
    /** Called when the activity is first created. */

        private TextView text;
        private LocationManager manager;
        private LocationListener listener;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        text = (TextView) findViewById(R.id.Text);

        manager = (LocationManager) getSystemService
(Context.LOCATION_SERVICE);
        listener = new MyLocationListener();
        manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, listener);
    }

    private class MyLocationListener implements LocationListener{

                public void onLocationChanged(Location location) {
                        // TODO Auto-generated method stub
                        if (location != null){
                                text.setText(text.getText() + \n + 
location.getLatitude() + , 
+ location.getLongitude() +  -  + location.getAccuracy());
                        }
                }

                public void onProviderDisabled(String provider) {
                        // TODO Auto-generated method stub

           

[android-beginners] Re: GPS Programming...

2009-09-08 Thread Xster

Hi,

The permissions and the settings are correct. I think it crashes if it
isn't.

I changed my function a bit such that the update request has a minimum
delay of 10 seconds and 10 meters. But I still get no updates. I can
get the last known location from the location manager so I figured
that works. Just the LocationListener's methods never gets called
somehow...

On Sep 7, 10:44 am, The Bear bernard.mcca...@googlemail.com wrote:
 Make sure you add the line
 permission android:name=android.permission.ACCESS_FINE_LOCATION/
 uses-permission
 to your AndroidManifest.xml file and you have enabled GPS satellites
 on your handset (won't work otherwise).

 Then try this:

 public class GPSTest extends Activity {
         private TextView text;
     private LocationManager manager;
     private LocationListener listener;

     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         text = (TextView)findViewById(R.id.Text);

         manager = (LocationManager) getSystemService
 (Context.LOCATION_SERVICE);
         Location myLocation = manager.getLastKnownLocation(gps);

         text.setText((Lat:  + myLocation.getLatitude()
                         + \nLLong:  + myLocation.getLongitude()));

         listener = new MyLocationListener();
         manager.requestLocationUpdates(gps ,1L, 10.0f,
 listener);
     }

     private class MyLocationListener implements LocationListener{

         public void onLocationChanged(Location location) {
                 // TODO Auto-generated method stub
                 if (location != null){
                         text.setText((Lat:  + location.getLatitude()
                                 + \nLLong:  + location.getLongitude()));
                 }
         }

         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
         }
     }

 }

 On Sep 4, 8:49 am, Xster x...@xiao-yu.com wrote:



  Hi,

  I'm trying to start a GPS program and I'm just trying out the first
  step to display coordinates as they change.

  I followedhttp://www.devx.com/wireless/Article/39239andused the
  LocationManager and LocationListener classes.

  Code:
  public class GPSTest extends Activity {
      /** Called when the activity is first created. */

          private TextView text;
          private LocationManager manager;
          private LocationListener listener;

      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          text = (TextView) findViewById(R.id.Text);

          manager = (LocationManager) getSystemService
  (Context.LOCATION_SERVICE);
          listener = new MyLocationListener();
          manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
  0, 0, listener);
      }

      private class MyLocationListener implements LocationListener{

                  public void onLocationChanged(Location location) {
                          // TODO Auto-generated method stub
                          if (location != null){
                                  text.setText(text.getText() + \n + 
  location.getLatitude() + , 
  + location.getLongitude() +  -  + location.getAccuracy());
                          }
                  }

                  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

                  }

      }

  }

  However, once I run the code on the phone, the GPS icon is seen
  flashing but nothing happens. The method onLocationChanged is never
  reached (according to breakpoints). What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: GPS Programming...

2009-09-07 Thread The Bear

Have you enabled GPS satellites in Settings Security  location 
Enable GPS satellites ?


On Sep 4, 8:49 am, Xster x...@xiao-yu.com wrote:
 Hi,

 I'm trying to start a GPS program and I'm just trying out the first
 step to display coordinates as they change.

 I followedhttp://www.devx.com/wireless/Article/39239and used the
 LocationManager and LocationListener classes.

 Code:
 public class GPSTest extends Activity {
     /** Called when the activity is first created. */

         private TextView text;
         private LocationManager manager;
         private LocationListener listener;

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         text = (TextView) findViewById(R.id.Text);

         manager = (LocationManager) getSystemService
 (Context.LOCATION_SERVICE);
         listener = new MyLocationListener();
         manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
 0, 0, listener);
     }

     private class MyLocationListener implements LocationListener{

                 public void onLocationChanged(Location location) {
                         // TODO Auto-generated method stub
                         if (location != null){
                                 text.setText(text.getText() + \n + 
 location.getLatitude() + , 
 + location.getLongitude() +  -  + location.getAccuracy());
                         }
                 }

                 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

                 }

     }

 }

 However, once I run the code on the phone, the GPS icon is seen
 flashing but nothing happens. The method onLocationChanged is never
 reached (according to breakpoints). What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: GPS Programming...

2009-09-07 Thread The Bear

Make sure you add the line
permission android:name=android.permission.ACCESS_FINE_LOCATION/
uses-permission
to your AndroidManifest.xml file and you have enabled GPS satellites
on your handset (won't work otherwise).

Then try this:

public class GPSTest extends Activity {
private TextView text;
private LocationManager manager;
private LocationListener listener;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

text = (TextView)findViewById(R.id.Text);

manager = (LocationManager) getSystemService
(Context.LOCATION_SERVICE);
Location myLocation = manager.getLastKnownLocation(gps);

text.setText((Lat:  + myLocation.getLatitude()
+ \nLLong:  + myLocation.getLongitude()));

listener = new MyLocationListener();
manager.requestLocationUpdates(gps ,1L, 10.0f,
listener);
}

private class MyLocationListener implements LocationListener{

public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
if (location != null){
text.setText((Lat:  + location.getLatitude()
+ \nLLong:  + location.getLongitude()));
}
}

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
}
}
}

On Sep 4, 8:49 am, Xster x...@xiao-yu.com wrote:
 Hi,

 I'm trying to start a GPS program and I'm just trying out the first
 step to display coordinates as they change.

 I followedhttp://www.devx.com/wireless/Article/39239and used the
 LocationManager and LocationListener classes.

 Code:
 public class GPSTest extends Activity {
     /** Called when the activity is first created. */

         private TextView text;
         private LocationManager manager;
         private LocationListener listener;

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         text = (TextView) findViewById(R.id.Text);

         manager = (LocationManager) getSystemService
 (Context.LOCATION_SERVICE);
         listener = new MyLocationListener();
         manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
 0, 0, listener);
     }

     private class MyLocationListener implements LocationListener{

                 public void onLocationChanged(Location location) {
                         // TODO Auto-generated method stub
                         if (location != null){
                                 text.setText(text.getText() + \n + 
 location.getLatitude() + , 
 + location.getLongitude() +  -  + location.getAccuracy());
                         }
                 }

                 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

                 }

     }

 }

 However, once I run the code on the phone, the GPS icon is seen
 flashing but nothing happens. The method onLocationChanged is never
 reached (according to breakpoints). What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: GPS Programming...

2009-09-05 Thread cellurl

GPS code example. Doesn't display coords, but maybe useful..
http://code.google.com/p/speedlimit/source/browse/trunk/Wikispeedia/src/org/wikispeedia/translate/Translate.java
-jp


On Sep 4, 2:49 am, Xster x...@xiao-yu.com wrote:
 Hi,

 I'm trying to start a GPS program and I'm just trying out the first
 step to display coordinates as they change.

 I followedhttp://www.devx.com/wireless/Article/39239and used the
 LocationManager and LocationListener classes.

 Code:
 public class GPSTest extends Activity {
     /** Called when the activity is first created. */

         private TextView text;
         private LocationManager manager;
         private LocationListener listener;

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         text = (TextView) findViewById(R.id.Text);

         manager = (LocationManager) getSystemService
 (Context.LOCATION_SERVICE);
         listener = new MyLocationListener();
         manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
 0, 0, listener);
     }

     private class MyLocationListener implements LocationListener{

                 public void onLocationChanged(Location location) {
                         // TODO Auto-generated method stub
                         if (location != null){
                                 text.setText(text.getText() + \n + 
 location.getLatitude() + , 
 + location.getLongitude() +  -  + location.getAccuracy());
                         }
                 }

                 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

                 }

     }

 }

 However, once I run the code on the phone, the GPS icon is seen
 flashing but nothing happens. The method onLocationChanged is never
 reached (according to breakpoints). What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---