We identified all essential Anastrepha obliqua (Macquart) resources (i.e., food, shelter, oviposition substrate [larval rearing medium], sites to perform sexual activities, and pupation medium) within a diversified agroecosystem (plum trees planted adjacent to mango trees), and examined the relationship between the spatial arrangement and temporal characteristics (e.g., variable degree of foliage coverage in plum trees) of habitat patches and resource use by local fly populations. Patterns of resource use were correlated with habitat characteristics (e.g., availability of shade, temperature, relative humidity, light intensity) and varied significantly between sexes. Overall, females used plum trees for feeding and oviposition, whereas males used them only for feeding. In contrast, females principally used mango trees for resting and feeding and males for sexual activities (courtship, copulation) and resting. We report significant differences in fly sightings according to sex, hour of day, and microhabitat. Of all fly sightings in the plum microhabitat (n = 396), 72.2% were females. In the mango microhabitat, 33.5% of 424 individuals sighted were female. Flies moved back and forth between microhabitats, especially during early morning and late afternoon. We also provide data on sightings of the fly parasitoid Doryctobracon aerolatus (Szepligeti) in plum trees and adjacent native vegetation. The high degree of behavioral plasticity observed seems to allow flies to respond efficiently to a heterogeneous and variable environment. We discuss the theoretical and practical implications of our results with respect to insect behavioral responses to variable environments, insect movement, and control strategies based on habitat manipulation (use of trap crops).