Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had this problem so I have tested the example below. The solution relies on calling "startActivity" from the MapActivity context. </p> <p>If your map is actually working with overlays then you have already passed the MapView Context to your custom ItemizedOverlay constructor and you probably assigned the MapView Context to a class variable called mContext (I'm making assumptions that you followed Google's MapView example). So in your custom Overlay's onTap function, do this: </p> <pre><code> @Override protected boolean onTap(int index) { Intent intent = new Intent(mContext, ActivityYouAreTryingToLaunch.class); mContext.startActivity(intent); return true; } </code></pre> <p>But you probably want to pass something to the new Activity you are trying to launch so your new activity can do something useful with your selection. So...</p> <pre><code> @Override protected boolean onTap(int index) { OverlayItem item = mOverlays.get(index); //assumption: you decided to store an "id" in the snippet so you can associate this map location with your new Activity long id = Long.parseLong(item.getSnippet()); //Snippet is a built-in String property of an Overlay object. //pass an "id" to the class so you can query Intent intent = new Intent(mContext, ActivityYouAreTryingToLaunch.class); String action = Intent.ACTION_PICK; //You can substitute with any action that is relevant to the class you are calling //I create a URI this way because I append the id to the end of the URI (lookup the NotePad example for help because there are many ways to build a URI) Uri uri = ContentUris.withAppendedId(Your_CONTENT_URI, id); //set the action and data for this Intent intent.setAction(action); intent.setData(uri); //call the class mContext.startActivity(intent); return true; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload