NullPointerException
NullPointerException

Reputation: 37579

It is possible to avoid Android to close a non visible activity?

I have an activity non visible, with some variables that must be accesed by static way. This activity can't be a service, because it is a MapView activity.

I need to access some static varibales of the activity anytime. I know that Android can close suspended activities (non visible activities) so.... how can i avoid it? i need that my suspended non visible activitity never get's deleted by Android.

The variable that i need to access staticly is a the own MapActivity instance variable because i need to pass it to another mapView objects from other activities

public class OsmMapActivity extends MapActivity {
    public static OsmMapActivity instance;      
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View v = new View(this);
        setContentView(v);
        instance=this;

Upvotes: 0

Views: 141

Answers (1)

sebastianf182
sebastianf182

Reputation: 9978

How many variables do you have? I would create a singleton and manage those with maybe SharedSettings. You can create a POJO and save it.

Also, you could make an object, implement Parcelable interface and pass it to the Activity where you need the information.

Upvotes: 1

Related Questions