I have several Overlays drawn on a MapView with ItemizedOverlay, and an onTap that works when I first start my app. However, if I press the Back button on the Android then start my app again the onTap does not work at all. Other touch sensative operations work fine, like long press on the map and several face buttons. It is also fine if I press the Home button on the phone then go back into my app, so its only on the Back button. It will also work if I first open another app like the Maps app, then go back into my app, acting like a reset.
Overriding the onBackPressed method to move the task to the background also does not work, does anyone have any ideas what would cause this? It happens in both the emulator and on a real device.
I don't know if it will help but here is the relevent code:
public OverlayManager(MapsTest launcher)
{
m_mapView = (MapView)m_activity.findViewById(R.id.mapview);
// init the list to the mapview list and clear it out
m_overlayList = m_mapView.getOverlays();
m_overlayList.clear();
// create an overlay list for each overlay type
for( OverlayTypes o : OverlayTypes.values() )
{
m_itemOverlay[o.ordinal()] = new OverlayList(m_context.getResources().getDrawable(OverlayData.getInstance().getDrawableID(o)));
}
// init the SMS sender
m_smsSender = new SMSSender();
m_mapMenu = new MapMenu(launcher, this);
m_overlayList.add(m_mapMenu);
m_mapView.invalidate();
}
public class OverlayList extends ItemizedOverlay<MapOverlayItem>
{
private ArrayList<MapOverlayItem> m_items = new ArrayList<MapOverlayItem>();
private int m_lastSelectedItem = 0;
public OverlayList(Drawable d)
{
super(d);
}
@Override
protected boolean onTap(int index)
{
if( !ProgramState.getInstance().recentStateChange() )
{
m_lastSelectedItem = index;
OverlayData.getInstance().setLastSelectedType(m_items.get(index).getMarkerType());
InfoBalloon.show(m_items.get(index));
}
return true;
}
}