I'm working on an app that uses osmdroid and I'm currently trying to just display the current user location on the map. I haven't set up a marker to actually mark where the current location is mainly because I don't think any of the approaches I've taken have really worked. Below is my most recent attempt taken from the following question (Question code is from). Using the debugger I can see that its having trouble firing whats inside the run() method. It just seems to skip those lines when I'm stepping through the code. Anyone have any help they could give here? Do I have to explicitly call run? I thought that the the purpose of runOnFirstFix but maybe I have it wrong. Thanks!
Main Activity:
GpsMyLocationProvider provider = new GpsMyLocationProvider(this);
provider.addLocationSource(LocationManager.NETWORK_PROVIDER);
locationOverlay = new MyLocationNewOverlay(provider, map);
locationOverlay.enableFollowLocation();
locationOverlay.runOnFirstFix(new Runnable() {
public void run() {
Log.d("MyTag", String.format("First location fix: %s", locationOverlay.getLastFix()));
mapController.animateTo(locationOverlay.getMyLocation());
}
});
map.getOverlayManager().add(locationOverlay);
map.invalidate();
}
public void onResume(){
super.onResume();
Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
locationOverlay.enableMyLocation();
}
Android Manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />