How do I manipulate a View from another class in Android? - android

I have a handler for receiving SMS in a seperate class. How can I make it change the view elements when the handler is executed?
Here is my code:
public class MainActivity extends MapActivity {
MapView mapView;
MapController mc;
GeoPoint p;
private int carNumber;
private String langt;
private String longt;
CheckedTextView text;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SmsReceiver smsreceiver = new SmsReceiver();
draw();
}
public void draw() {
mapView = (MapView) findViewById(R.id.mapView);
LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
#SuppressWarnings("deprecation")
View zoomView = mapView.getZoomControls();
zoomLayout.addView(zoomView, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mapView.displayZoomControls(true);
mc = mapView.getController();
double lat = Double.parseDouble("31.977185185185185");
double lng = Double.parseDouble("35.205925925925925");
p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
mc.animateTo(p);
mc.setZoom(17);
MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
mapView.invalidate();
}
}
}
Here is the SMS Receiver class:
public class SmsReceiver extends BroadcastReceiver {
MapView mapView;
MapController mc;
GeoPoint p;
private int carNumber;
private String langt;
private String longt;
CheckedTextView text;
public SmsReceiver(MapView mapView) {
this.mapView = mapView;
}
private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
#SuppressLint("NewApi") #Override
public void onReceive(final Context context, final Intent intent) {
if (intent != null && SMS_RECEIVED.equals(intent.getAction())) {
final SmsMessage smsMessage = extractSmsMessage(intent);
processMessage(context, smsMessage);
}
}
#SuppressLint("NewApi") private SmsMessage extractSmsMessage(final Intent intent) {
final Bundle pudsBundle = intent.getExtras();
final Object[] pdus = (Object[]) pudsBundle.get("pdus");
final SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) pdus[0]);
return smsMessage;
}
}
I want to modify the MapView inside the SmsReceiver class.
Thank you.

Define an interface and use a callback to let the activity know that an SMS has been received.
public Interface SmsReceivedListener {
void onSmsReceived(int arg1, string arg2); ..<----add arguments you want to pass back
}
In your SMS class
ArrayList<SmsReceivedistener> listeners = new ArrayList<SmsReceivedistener>();
...
public void setSmsReceivedistener(SmsReceivedistenerlistener){
listeners.add(listener);
}
When you receive an SMS
for (SmsReceivedistener listener:listeners){
listener.onSmsReceived(arg1, arg2);
}
In your Activity:
public class MainActivity extends MapActivity implements SmsReceivedListener {
...
#Override
public void onCreate(Bundle savedInstanceState)
{
...
smsReceiver.setSmsReceivedistener(this);
...
}
public void onSmsReceived(int arg1, string arg2){
// do whatever you need to do
}
All from memory so please excuse typos and you should improve the SMS class by adding removeSmsReceivedistener and checking that you do not add the same listener twice in setSmsReceivedistener.
Note. Because you use an interface, any class (not just an Activity) can implement it so you can update anywhere in your app. The smsReceiver class doesn't know or care. It just calls the listeners, if any are registered.

Try this
TextView bt1 =m_activity.findViewById(R.id.textview1);
In the above example where view bt1 is from another class.you can access bt1 by using class instance and get the id.Now,do what ever you want do with bt1 instance.
Note: Make Sure bt1 is public in another class

Add this to your onReceive() method:
if (context instanceof MainActivity) {
//modify the map
((MainActivity)context).findViewById(...);
}

Related

onCreate wasn't called by the main class

I've read a lot of articles but none of them could fix my problem of not calling the onCreate-method in the class XMLParsingExample.
The log-statement in the onCreate didn't show output and tracing shows that the class is exited after boolean finished=false and thus not running the onCreate.
Here the codes:
public class MyMap extends MapActivity {
private MapView mapView;
private MapController mc;
private OverlayItem overlayItem;
private List<Overlay> mapOverlays;
private Drawable drawable;
private Drawable drawable2;
private MyItemizedOverlay itemizedOverlayMyLoc;
private MyItemizedOverlay itemizedOverlayRust;
private LocationManager locMgr;
private MyLocationListener locLstnr;XMLParsingExample mXMLParsingExample;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mc = mapView.getController();
mapView.setBuiltInZoomControls(true);
locMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locLstnr = new MyLocationListener();
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locLstnr);
mapOverlays = mapView.getOverlays();
// first overlay
drawable = getResources().getDrawable(R.drawable.marker2);
itemizedOverlayMyLoc = new MyItemizedOverlay(drawable, mapView);
// LAT LONG
GeoPoint uwLoc = new GeoPoint((int)(52.22778*1E6),(int)(6.10428*1E6));
overlayItem = new OverlayItem(uwLoc, "Uw locatie", "http://www.nu.nl");
itemizedOverlayMyLoc.addOverlay(overlayItem);
mapOverlays.add(itemizedOverlayMyLoc);
// Rustpunten overlay
drawable2 = getResources().getDrawable(R.drawable.rmarker3);
itemizedOverlayRust = new MyItemizedOverlay(drawable2, mapView);
mXMLParsingExample = new XMLParsingExample();
and here the class which where the oncreate isn't called:
public class XMLParsingExample extends Activity {
/** Create Object For SiteList Class */
public SitesList sitesList = null;
public ProgressDialog progressDialog;
boolean finished=false;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i("onCreate", "onCreate started");
}
Starting a new Activity is not done by instantiating it (new XMLParsingExample();), but with an intent, for example:
Intent intent = new Intent(this, XMLParsingExample.class);
startActivity(intent);
Take a look at the here.
Binyamin Sharet is correct.
I think you are confusing a creator method, which does get called when you allocate an object, and onCreate(), which is an Android lifecycle callback function that gets called automatically by the framework at the appropriate time.
A creator function doesn't usually have 'create' in its name; it shares the name of the class whose object you are instantiating. In your case, the creator would be called XMLParsingExample().
For more information about Android lifecycle callbacks, see http://developer.android.com/guide/topics/fundamentals/activities.html.

Starting a new activity from a subclass with a listener

In order to detect map movements and gestures and use the lazy loading support for my map items I'm trying to work with this library: http://code.google.com/p/mapview-overlay-manager/.
I've setup a map attached the overlayManager and the events are coming through just fine. I can throw a toast from the listener just fine. When I get Application context it is not null.
I'm stuck trying to launch an intent from the ManagedOverlay class. Specifically in the onDoubleTap method below I'm trying to launch an intent and I get this error message:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
I think I generally understand that I need to call back to the MapActivity subclass and have it launch the intent or I need to do something with the context differently. I'm having trouble ironing out the specifics however. Any assistance appreciated.
public class SiteMapRev2 extends MapActivity {
private MapView mapView;
private OverlayManager overlayManager;
private MapController mapController;
private MyLocationOverlay userLocationOverlay;
private ArrayList<SiteSummary> sitesRoster = null;
private Drawable siteIcon;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
overlayManager = new OverlayManager(this, mapView);
sitesRoster = new ArrayList<SiteSummary>();
userLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(userLocationOverlay);
mapController = mapView.getController();
mapController.setZoom(14);
siteIcon = this.getResources().getDrawable(R.drawable.marker2);
}
#Override
public void onStart() {
super.onStart();
Drawable defaultmarker = getResources().getDrawable(R.drawable.marker2);
ManagedOverlay managedOverlay = overlayManager.createOverlay("sites", defaultmarker);
managedOverlay.setOnOverlayGestureListener(new ManagedOverlayGestureDetector.OnOverlayGestureListener(){
public boolean onDoubleTap(MotionEvent arg0, ManagedOverlay arg1,
GeoPoint arg2, ManagedOverlayItem arg3) {
if (arg3 == null) {
return false;
}
else {
**SiteOverlayItem thisItem = (SiteOverlayItem) arg3;
String siteIDAsString = Integer.toString(thisItem.getSiteID());
Context c = getApplicationContext();
Intent showSiteDetails = new Intent(c,SiteDetailActivity.class);
Log.d(toString(), "intent = " + showSiteDetails.toString());
showSiteDetails.setData(Uri.parse(siteIDAsString));
c.startActivity(showSiteDetails);
return true;**
}
}
Instead of getting the application context, I would do this:
SiteMapRev2.this.startActivity(showSiteDetails);
which starts the activity from your map activity as you normally would.
Set this Flag to your intent, Logcat is too smart, try to understand what is says to you ;)
showSiteDetails.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Android : Back button is acting odd

I have a strange problem and really dont know where to start debug. I have 2 activities one that holds a googlemap view and when the user taps the marker on the view i start a new activity that shows a detailed description of that marker. If i hit the back buttton on my detalied activity it returns me to the map activity, so far so good. BUT if i tap a new (or same) marker i get to the detailed activity again (all fine) if i try to hit the back button again i get returned to the detailed activity that i tapped the very first time, and i can hit back once more and finaly get to the map activity again.
if i keep debugggin i can get up to 10 activities that i have to push back on before i finaly get to the map activity again
what the heck is going on ? does android forget history or something due to i implement the map activity instead of activity ?
anyone that has an idea of where to start looking for the problem
Here comes a lot of code:
map activity
public class SpotGuideMapActivity extends MapActivity
{
protected MapView mapView;
protected MapController mapController;
protected List<Overlay> mapOverlays;
protected Drawable overlayIcon;
protected SpotGuideOverlay spotsOverlay;
protected MyLocationOverlay myLocOverlay;
protected ArrayList<SpotItem> _spots;
protected Button ButtonHome;
protected Button ButtonPreferences;
protected Intent _intent = null;
private SpotGuideDbAdapter _spotDbAdapter;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.spot_map);
_intent = getIntent();
ActivityHelper.createInstance(this).setTopBarTitle("Spot kortet");
ButtonPreferences = (Button)findViewById(R.id.btnPreferences);
ButtonPreferences.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
startActivity(new Intent(getApplicationContext(), GlobalPreferencesActivity.class));
overridePendingTransition(R.anim.slide_right_in,R.anim.slide_right_out);
}
});
ButtonHome = (Button)findViewById(R.id.btnHome);
ButtonHome.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
startActivity(new Intent(getApplicationContext(), HomeActivity.class));
overridePendingTransition(R.anim.slide_left_in,R.anim.slide_left_out);
}
});
//mapView.invalidate();
}
#Override
protected void onResume()
{
super.onResume();
if(_intent.hasExtra("latitude") && _intent.hasExtra("longitude"))
{
String latitude = _intent.getStringExtra("latitude");
String longitude = _intent.getStringExtra("longitude");
double lat = Double.parseDouble(latitude);
double lon = Double.parseDouble(longitude);
GeoPoint point = new GeoPoint((int)(lat * 1E6) , (int)(lon * 1E6));
initMapView(point);
}
else
{
initMapView(null);
}
drawSpotMarkers();
}
#Override
protected void onPause()
{
super.onPause();
myLocOverlay.disableCompass();
myLocOverlay.disableMyLocation();
}
protected void initMapView(GeoPoint centerPoint)
{
mapView = (MapView)findViewById(R.id.spotGuideMap);
mapView.setBuiltInZoomControls(true);
mapController = mapView.getController();
//current location overlayer
myLocOverlay = new MyLocationOverlay(this, mapView);
myLocOverlay.enableCompass();
myLocOverlay.enableMyLocation();
mapView.getOverlays().add(myLocOverlay);
GeoPoint point = null;
if(centerPoint == null)
{
point = myLocOverlay.getMyLocation();
if(point == null)
{
point = new GeoPoint((int)(55.5616508394963 * 1E6) , (int)(12.563638687133789 * 1E6));
}
}
else
{
point = centerPoint;
}
//get the last know location, be fresh so use last fix
//Location location = myLocOverlay.getLastFix();
//GeoPoint locationPoint;
//locationPoint = new GeoPoint((int)(location.getLatitude() * 1E6) , (int)(location.getLongitude() * 1E6));
mapController.animateTo(point);
mapController.setZoom(10);
}
protected void drawSpotMarkers()
{
mapOverlays = mapView.getOverlays();
overlayIcon = getResources().getDrawable(R.drawable.map_icon_pink);
spotsOverlay = new SpotGuideOverlay(overlayIcon, this);
_spotDbAdapter = new SpotGuideDbAdapter(this).Open();
_spots = _spotDbAdapter.getAllSpots();
for (SpotItem spot : _spots)
{
double lat = Double.parseDouble(spot.getLatitude());
double lon = Double.parseDouble(spot.getLongitude());
GeoPoint point = new GeoPoint((int)(lat * 1E6) , (int)(lon * 1E6));
OverlayItem overlayitem = new OverlayItem(point, spot.getSpotTitle(), Integer.toString(spot.getId()));
spotsOverlay.addOverlay(overlayitem);
}
mapOverlays.add(spotsOverlay);
}
#Override
protected boolean isRouteDisplayed()
{
return false;
}
}
detailed activity
public class SpotGuideDescriptionActivity extends BaseActivity
{
private SpotGuideDbAdapter _spotDbAdapter;
protected Button ButtonHome;
protected Button ButtonPreferences;
protected Button ButtonBacktoMap;
protected TextView tvSpotTitle;
protected TextView tvSpotType;
protected TextView tvWindDirection;
protected TextView tvContent;
protected Intent _intent = null;
protected SpotItem item;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.spot_description);
_intent = getIntent();
this.getActivityHelper().setTopBarTitle("Spot beskrivelse");
tvSpotTitle = (TextView)findViewById(R.id.spotDescTitle);
tvSpotType = (TextView)findViewById(R.id.spotDescType);
tvWindDirection = (TextView)findViewById(R.id.spotDescWind);
tvContent = (TextView)findViewById(R.id.spotDescContent);
ButtonBacktoMap = (Button)findViewById(R.id.btnBackToMap);
ButtonBacktoMap.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent intent = new Intent(getApplicationContext(), SpotGuideMapActivity.class);
intent.putExtra("latitude", item.getLatitude());
intent.putExtra("longitude", item.getLongitude());
startActivity(intent);
overridePendingTransition(R.anim.slide_left_in,R.anim.slide_left_out);
}
});
ButtonPreferences = (Button)findViewById(R.id.btnPreferences);
ButtonPreferences.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
startActivity(new Intent(getApplicationContext(), GlobalPreferencesActivity.class));
overridePendingTransition(R.anim.slide_right_in,R.anim.slide_right_out);
}
});
ButtonHome = (Button)findViewById(R.id.btnHome);
ButtonHome.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
startActivity(new Intent(getApplicationContext(), HomeActivity.class));
overridePendingTransition(R.anim.slide_left_in,R.anim.slide_left_out);
}
});
init();
}
private void init()
{
if(_intent.hasExtra("spot_id"))
{
int id = _intent.getIntExtra("spot_id", 0);
_spotDbAdapter = new SpotGuideDbAdapter(this).Open();
item = _spotDbAdapter.getSpot(id);
tvSpotTitle.setText(item.getSpotTitle());
tvSpotType.setText(item.getSpotType());
tvWindDirection.setText(item.getWindDirections());
tvContent.setText(item.getSpotDescription());
}
}
}
And i init the tap in my OverlayItem like this
public boolean onTap(int index)
{
OverlayItem item = mOverlays.get(index);
Intent descIntent = new Intent(currentContext.getApplicationContext(), SpotGuideDescriptionActivity.class);
descIntent.putExtra("spot_id", item.getSnippet());
currentContext.startActivity(descIntent);
return false;
}
it is not the BackToMap button that i use, it is the back button on all phones
I haven't worked with maps, so I may be off my rocker. But the fact that you are calling initMapView() in OnResume() might be creating two markers one on top of the other (and again, every time you go back). So when you think you are taping on one marker, you are actually taping on multiple markers.
That's just off the top of my head, and can be total malarkey.
A quick solution would be to #Override onBackPressed() to open the map activity back up. This might lead to you having to do it to navigate the entire app, though. If it's just that map page and the overlay with more info, you can easily just have this on the page that is duplicating:
#Override
onBackPressed(){
Intent i = new Intent(this, Activity.class);
startActivity(i);
}
then on the activity with the mapview
#Override
onBackPressed(){
moveTaskToBack(true);
}

OnTap() event on map is not fired

Hello i am unable to fire ontap() event
i want to add a marker whenever i tap on map, and when i tap on another geopoint the first marker should disappear and the marker should be added on new location...
till now i have come to this point..can anybody tell me where am i going wrong!!
thanks in advance
Source Code
public class GetLocation extends MapActivity implements OnClickListener {
MapView mapView;
MapController mc;
GeoPoint p;
int range;
String category;
Button view, traffic;
private static final String Tag = "GetLocation class";
ZoomControls zoomControls;
Canvas canvas;
MapOverlay itemizedoverlay;
List<Overlay> mapOverlays;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("Tag","Inside onCreate");
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.myMapView1);
LinearLayout zoom = (LinearLayout)findViewById(R.id.zoom);
mapView.setReticleDrawMode(
MapView.ReticleDrawMode.DRAW_RETICLE_UNDER);
// Drawable drawable = this.getResources().getDrawable(R.drawable.mark);
view=(Button)findViewById(R.id.BtnView);
traffic=(Button)findViewById(R.id.BtnTraffic);
Bundle extra=getIntent().getExtras();
if(extra != null)
{
category=extra.getString("category");
range=extra.getInt("range");
}
view.setOnClickListener(this);
traffic.setOnClickListener(this);
zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mc.zoomIn();
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mc.zoomOut();
}
});
mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.mark);
itemizedoverlay = new MapOverlay(drawable,this);
mc = mapView.getController();
mapView.invalidate();
mc.setZoom(17);
mapView.invalidate();
// mapView.setSatellite(true);
mapView.setStreetView(true);
// mapView.setOnClickListener(this);
Log.d("Tag","Exit onCreate");
}
class MapOverlay extends com.google.android.maps.ItemizedOverlay<OverlayItem>
{
private ArrayList<OverlayItem> mOverlay = new ArrayList<OverlayItem>();
private Context mContext;
private boolean isPinch = false;
public MapOverlay(Drawable defaultMarker,Context context) {
super(boundCenterBottom((defaultMarker)));
mContext = context;
// TODO Auto-generated constructor stub
}
public void addOverlayItem(OverlayItem overlayItem)
{
if(!mOverlay.contains(overlayItem)){
mOverlay.add(overlayItem);
}
populate();
}
#Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return null;
}
#Override
public int size() {
// TODO Auto-generated method stub
return mOverlay.size();
}
public boolean onTap(GeoPoint p, MapView map)
{
if ( isPinch )
{
Log.i("onTap","in if!");
return false;
}
else
{
Log.i("onTap","TAP!");
if ( p!=null )
{
OverlayItem overlayitem = new OverlayItem(p," ", " ");
itemizedoverlay.addOverlayItem(overlayitem);
mapOverlays.add(itemizedoverlay);
Toast.makeText(getBaseContext(),
p.getLatitudeE6() / 1E6 + ",on Tap" +
p.getLongitudeE6() /1E6 ,
Toast.LENGTH_SHORT).show();
Log.d("Tag","Exit TAp");
return true; // We handled the tap
}
else
{
return false; // Null GeoPoint
}
}
}
}
this is my code
hope you can get some idea
Point p1=new Point(0,0);
mapView.getProjection().toPixels(mapPoint, p1);// mapPoint is GeoPoint object
inDrag=item; // item get from List object and inDrag is an OverlayItem object
items.remove(inDrag); items is list object
populate();
GeoPoint pt=mapView.getProjection().fromPixels(p1.x+xDragImageOffset,p1.y);
OverlayItem toDrop=new OverlayItem(pt, inDrag.getTitle(),inDrag.getSnippet());
items.add(toDrop);
populate();
Have a look to this article: http://mobiforge.com/developing/story/using-google-maps-android
It has a part called: "Adding Markers"
Also, here you have another more advanced example:
https://github.com/commonsguy/cw-advandroid/blob/master/Maps/NooYawkTouch/src/com/commonsware/android/maps/NooYawk.java
Hope it helps you.
the function on tap in itemizedoverlay is basically fired when the user taps on a marker
u wil hav to create a class extending overlay to detect taps .
check this overlays example

Inflate balloon when item is selected

I have a map activity that has many pins of map, and when I click a pin, a custom balloon opens, showing some information about that pin. Also, I have a search bar, where if you type the name of a knob, the info appears there, but I want it to go to that searched pin.
Example: on the map you have different vegetables pins, and when you search carrot, the search list will show the element carrot, and when you click on it, the balloon for the carrot pin will inflate. So, my question is : is there some sort of OnTap() void method ? I know, that OnTap(int index) returns a boolean.
create your own itemized overlay, and override the onTap method, and in your main class, make an instance of the itemized overlay, and call overlay.onTap(point)
Sample code:
public class MyItemizedOverlay<Item> extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> m_overlays;
private MapView mapView;
final MapController mc;
public MyItemizedOverlay(Drawable defaultMarker, MapView mapView) {
super(boundCenterBottom(defaultMarker), mapView);
m_overlays = new ArrayList<OverlayItem>();
mc = mapView.getController();
populate();
}
public void addOverlay(OverlayItem overlay) {
m_overlays.add(overlay);
setLastFocusedIndex(-1);
populate();
}
public ArrayList<OverlayItem> getOverlays() {
return m_overlays;
}
public final boolean onTap(int index) {
GeoPoint point;
point = createItem(index).getPoint();
mc.animateTo(point);
return true;
}
...
}
In the main class
public class Main extends MapActivity {
private MapView mapView;
private List<Overlay> mapOverlays;
private MyItemizedOverlay overlay;
private Drawable pin;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
doAction();
}
private void doAction() {
mapView = (MapView)findViewById(R.id.map_view);
pin = res.getDrawable(R.drawable.pin);
overlay = new MyItemizedOverlay(pin, mapView);
GeoPoint point = new GeoPoint((int)(7*1E6),(int)(42*1E6));
overlayItem = new OverlayItem(point, "title", "text");
overlay.addOverlay(overlayItem);
mapOverlays = mapView.getOverlays();
mapOverlays.add(overlay);
//we tap the point here
overlay.onTap(0);
}
}

Categories

Resources