Zephyr
Zephyr

Reputation: 45

How to pass values from MapOverlay

I want to pass the values from MapOverlay class to another class. I tried to use an Intent

Intent i = new Intent(getApplicationContext(), AnotherClass.class);
i.putExtra("value1", x1);
i.putExtra("value2", y1);
startActivity(i);

but Eclipse alerts me "The method getApplicationContext() is undefined for the type MapOverlay" so I can't use this method to pass the values. Please advise me on how I should do this.

Thanks in advance.

Upvotes: 0

Views: 56

Answers (1)

Praveenkumar
Praveenkumar

Reputation: 24496

I suggest you to Use GetSet method for this -

In your Mapoverlay class -

GetSet gs = new GetSet();
gs.setFname(value1,value2);

Getset.java

public class GetSet 
{
public static String fName[];
@SuppressWarnings("static-access")
public void setFname(String value1, String value2)
{
    fName[] = new String[2];
    fName[1] = value1;
    fName[2] = value2;
}

@SuppressWarnings("static-access")
public String[] getfName()
{
    return this.fName;
}
}

And, whereever you need that values, just get like below code -

GetSet gs = new GetSet();
resultofoverlay = gs.getFname();

Here, resultofoverlay is a string array. Try to declare this as global.

Upvotes: 1

Related Questions