Cognitive Radio (CR) is a new concept in wireless communication systems that aims at enabling opportunistic spectrum access (OSA) to licensed frequencies by secondary users (SU). Specifically, CR systems are expected to detect idle periods when licensed spectrum is not used by primary users (PU), to take advantage of them for providing service to SU, and to release them when PU become active. Thus, OSA performance relies on the ability of the SU to accurately detect the PU activity, and this paper examines the relationship between changes in the PU activity and the performance of energy-based spectrum sensing. Analytical expressions for the probabilities of detection and false alarm are derived by explicitly considering the probability that the PU state switches while the SU is sensing the spectrum, and are corroborated with numerical results obtained from simulations.