As part of an application for registrer whether a vehicle can pass the
next traffic light without having stop for red light, I am trying to
get the GPS Location.
So far I have tried the code below, but the HTC Tattoo telephone keeps
stopping the application.
The reason is that the List providers remains empty.
Is there any way that I can extend my code, so I can understand why
providers remains empty.
I know I get a NullPointerException, but I don't know why as GPS is
enabled.
I will really appreciate your help on how to get
- status of the GPS
- content of providers.
The code is listed below (I don't get any compilation errors):
protected void onResume() {
List providers;
final String tag = "readdata";
super.onResume();
locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
providers = locationManager.getProviders(true);
if (!providers.isEmpty()) {
location = locationManager.getLastKnownLocation((String)
providers
.get(0));
locationManager.requestLocationUpdates((String)
providers.get(0),
15000, 1, this);
}
GeoPoint p = new GeoPoint((int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
mc.animateTo(p);
mc.setZoom(17);
mapView.setSatellite(true);
mapView.setStreetView(true);
mapView.invalidate();
}
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
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
To unsubscribe, reply using "remove me" as the subject.