Reputation: 12316
I'm trying to send data from an overlay to other activity with this class
public class Capas extends ItemizedOverlay<OverlayItem>
{
MapView Map;
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
@SuppressWarnings("unused")
private Context mContext;
public Capas(Drawable defaultMarker, Context context)
{
super(boundCenterBottom(defaultMarker));
mContext = context;
}
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView)
{
if (event.getAction() == 1) {
GeoPoint puntoTocado = mapView.getProjection().fromPixels((int) event.getX(),(int) event.getY());
Intent nuevoLugar=new Intent(Capas.this,editarLugar.class);
nuevoLugar.putExtra("latitud",puntoTocado.getLatitudeE6());
nuevoLugar.putExtra("longitud",puntoTocado.getLongitudeE6());
StartActivity()
}
return false;
}
}
But this return me the next error The constructor Intent(Capas, Class) is undefined.
I try with Intent nuevoLugar=new Intent(Capas.class,editarLugar.class);
Intent nuevoLugar=new Intent(this,editarLugar.class);
but anoone works
Upvotes: 0
Views: 118
Reputation: 14237
To create a a new intent you need to get access to a Context
instance. ItemizedOverlay
doesn't extend from it.
You have you initialize the intent like this:
Intent nuevoLugar=new Intent(mContext, editarLugar.class);
You need to make sure that editarLugar
is an Activity
.
But also, you need access to the activity. Since I think we can assume that you are creating it from an Activity you can launch it like this:
if(mContext instanceof Activity) {
((Activity)mContext).startActivity(nuevoLugar);
}
My bad, you can just call:
mContext.startActivity(nuevoLugar);
Upvotes: 2
Reputation: 4842
the first argument should be a Context. please try Intent nuevoLugar=new Intent(mContext,editarLugar.class);
Upvotes: 2
Reputation: 7505
In this case this should work:
Intent nuevoLugar = new Intent(mContext, editarLugar.class);
Provided that editarLugar extends Activity
and is declared in AndroidManifest.xml
.
And to start the activity:
mContext.startActivity(nuevoLugar);
Upvotes: 2