Arg.. This is frustrating:
All of a sudden (March 2012) MyLocationOverlay.enableCompass does not work. It works okay using Google APIs 14, but is leaves the screen all black on Google APIs 7 and Google APIs 8.
I would like to keep the compass functionality but since it is not essential I will just leave it disabled for now. I think this maybe a result of installing Android SDK Tools 16 over SDK Tools 15... Maybe this is a problem with my emulator setup or Eclipse? I have a strong feeling this issue will not occur on a real device.. The next step on my part will be to try it on another install of Eclipse/Android SDK but that's for another day...
Thank you for your help.
Here is my sample code: At first, onResume, I don't enable the compass... Everything works just fine. At second, onResume after onPause [hit the home button then reaccess the app], the black screen occurs. What's going on?
@Override
public void onCreate(Bundle state)
{
super.onCreate(state);
setContentView(MAP_LAYOUT);
MapView mv = (MapView) findViewById(MAP_VIEW);
mv.setBuiltInZoomControls(true);
List<Overlay> mapOverlays = mv.getOverlays();
Context c = getApplicationContext();
mLocation = new MyLocationOverlay(c,mv);
mapOverlays.add(mLocation);
}
@Override
public void onPause() {
super.onPause();
mLocation.disableCompass();
mLocation.disableMyLocation();
mCompassOn = true;
}
boolean mCompassOn = false;
@Override
public void onResume() {
super.onResume();
if( mCompassOn ) mLocation.enableCompass();
mLocation.enableMyLocation();
}
My Manifest Includes:
... <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="com.google.android.maps" /> ... </application> ...
And my layout includes, to match the correct debug-key store:
<com.google.android.maps.MapView
android:id="@+id/superMapView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:clickable="true"
android:apiKey="..." />
Eclipse Platform
Version: 3.7.0.v20110530-9gF7UHNFFt4cwE-pkZDJ7oz-mj4OSEIlu9SEv0f
Build id: I20110613-1736
Android Development Toolkit
Version: 16.0.1.v201112150204-238534
The question is similar to
http://groups.google.com/group/android-developers/browse_thread/thread/8928ffa71ef35f8a
but I would like to continue to use the compass...