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 <[email protected]> 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 [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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to