Thursday, 15 August 2013

Android using static booleans as flag to determine if activity is visible

Android using static booleans as flag to determine if activity is visible

I wanted to hear other opinions about using the following method to
determine from other activities or services if the activity is visible:
the method is about using static booleans as flags, which values depends
of activity life-cycle. I already implemented this solution and it seems
to work alright. However i have doubts whether this is a reliable
solution, because, from what i understand, the activity life-cycle is
contained inside of an instance of that Activity class, but static methods
or fields applies to all instances. For the activity, that visibility
status needs to be determined, ive used "singleTask" launchmode, so there
shouldnt be more than one instance. With that in mind, is it safe to
assume that the static boolean will 100% represent the actual status of my
activity?

No comments:

Post a Comment