GPS emulation

by olivier » Wed, 29 Apr 2009 01:07:49 GMT


Sponsored Links
 Hi all,

I am currently trying to simulate GPS fixs with android emulator, but
I encountered some problems. I can run the app, clic on the send
button in the emulator control, but, only the first click provides a
position. I am running an ubuntu jaunty, eclipse and SDK 1.5, on a
french system with the locale EN_US
Here is my code :

private class MyLocationListener implements LocationListener
            {
                @Override
                public void onLocationChanged(Location loc) {
                    if (loc != null) {
                        String s = "";
                        s += loc.getLatitude();
                        s += "   ";
                        s += loc.getLongitude();
                        Toast.makeText(getBaseContext(),
                            "Location changed : Lat: " + loc.getLatitude() +
                            " Lng: " + loc.getLongitude(),
                            Toast.LENGTH_SHORT).show();
                        Log.i("GPS", s);
                    }
                    else {
                        Log.i("Gps","loc_null");
                    }
                }

                @Override
                public void onProviderDisabled(String provider) {
                    // TODO Auto-generated method stub
                        Log.i("Gps","onProviderDisabled");
                }

                @Override
                public void onProviderEnabled(String provider) {
                    // TODO Auto-generated method stub
                        Log.i("Gps","onProviderEnabled");
                }

                @Override
                public void onStatusChanged(String provider, int status,
                    Bundle extras) {
                    // TODO Auto-generated method stub
                        Log.i("Gps","onStatusChanged : " + provider);
                }
            }

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       //---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);

    }

Can you tell me what I am doing wrong ?

Regards,

Olivier

--~--~---------~--~----~------------~-------~--~----~



GPS emulation

by ellipsoidmob...@googlemail.com » Wed, 29 Apr 2009 17:16:30 GMT


 Are you changing the location set in the emulator before each click,
or are you just sending the same location repeatedly?

I suspect (but don't know for sure) that even with distance & time set
to 0 in requestLocationUpdates, an update won't be generated if the
new location is identical to the old location.
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


GPS emulation

by Andreas Frey » Wed, 29 Apr 2009 17:28:38 GMT


 Hi,

i had a similar problem using the geo fix command - only the first
transmission of a newlocation worked.
Look @ here:



GPS emulation

by Olivier Tournaire » Wed, 29 Apr 2009 18:03:15 GMT


 i,

Hi,


I saw this post, same day as mine ;-)

I "solved" the problem with a dirty hack:


@Override
public void onLocationChanged(Location loc) {
if (loc != null) {
String s = "";
s += loc.getLatitude();
s += " ";
s += loc.getLongitude();
Log.i("GPS", s);
}
else {
Log.i("Gps","loc_null");
}
* lm.removeUpdates(locationListener);
lm.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
xxx,
xxx
locationListener); *
}

Crappy isn't it ?

Regards,

Olivier



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. SQL lite

I am writing a simple app with 3 text fields and a date picker I would
like to be able to save the data from these to an SQL lite DB, are
there any beginner tutorials on this or can some one here tell me how.
I have already created the DB using SQL Lite browser and saved it to
the assetts directory, I just need to be able to access it from code.

-- 

2. Highlight focus item on listview

Hi i was wondering I know by now how to make a list appear on Android.
but my new task is when i select the item on listview it just changes
colors like semi gets highlighted then goes away as i guess the
program has selected its object. what I wanted to know is there a way
to keep the highlighted focus on the item becuase i want to create it
so when i select the item i have buttons on the bottom and the user
can also make sure they selected the right item for the buttons?

-- 

3. Finding a development phone - how is the LG Optimus GT540?

4. doubts about wifi application

5. webview.loadUrl - native

6. Connection Center Settings

7. LVL and Google Apps accounts