Getting GPS data?
Posted
by svebee
on Stack Overflow
See other posts from Stack Overflow
or by svebee
Published on 2010-05-02T21:29:57Z
Indexed on
2010/05/02
21:38 UTC
Read the original article
Hit count: 404
Inside
public class IAmHere extends Activity implements LocationListener {
i have
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
}
@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
}
and
inside
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.iamhere);
i have
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
List<String> providers = lm.getProviders(true);
/* Loop over the array backwards, and if you get an accurate location, then break out the loop*/
Location l = null;
for (int i=providers.size()-1; i>=0; i--) {
l = lm.getLastKnownLocation(providers.get(i));
if (l != null) break;
}
double[] gps = new double[2];
if (l != null) {
gps[0] = l.getLatitude();
gps[1] = l.getLongitude();
}
gpsString = (TextView)findViewById(R.id.gpsString);
String Data = "";
String koordinata1 = Double.toString(gps[0]);
String koordinata2 = Double.toString(gps[1]);
Data = Data + koordinata1 + " | " + koordinata2 + "\n";
gpsString.setText(String.valueOf(Data));
but seems it's not working? Why? I mean even emulator doesn't want to send GPS data - When I click "send" via UI or console, nothing happens...?
Thank you.
© Stack Overflow or respective owner