first of all I want you to know, that anddev is a really great project and I hope, that it will become more and more known
I tried to play around with that interesting gps function of android, here is my code:
Using java Syntax Highlighting
- package com.example.gps;
- import android.app.Activity;
- import android.content.Context;
- import android.location.Location;
- import android.location.LocationListener;
- import android.location.LocationManager;
- import android.os.Bundle;
- import android.widget.TextView;
- public class gps extends Activity
- {
- private LocationManager lm;
- private LocationListener locationListener;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- //---use the LocationManager class to obtain GPS locations---
- lm = (LocationManager)
- getSystemService(Context.LOCATION_SERVICE);
- locationListener = new MyLocationListener();
- lm.requestLocationUpdates(
- LocationManager.GPS_PROVIDER,
- 0,
- 0,
- locationListener);
- }
- private class MyLocationListener implements LocationListener
- {
- @Override
- public void onLocationChanged(Location loc) {
- TextView tv = new TextView(gps.this);
- tv.setText("Location changed : Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude());
- setContentView(tv);
- }
- @Override
- public void onProviderDisabled(String provider) {
- // TODO Auto-generated method stub
- }
- @Override
- public void onProviderEnabled(String provider) {
- // TODO Auto-generated method stub
- }
- @Override
- public void onStatusChanged(String provider, int status,
- Bundle extras) {
- // TODO Auto-generated method stub
- }
- }
- }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
But I have two problems and it would be great, if we could solve them.
1. I can't update my GPS position by Eclipse (DDMS). Only via telnet "geo fix" - but why??
2. My application only shows the first location change. Afterwards nothing happens - why??
Thank you very much for your help and best regards from Berlin.


