These flies have no obvious structures or behaviors that are specifically related to defense against predators.
Medflies are attached by many parasitoid wasps. Some wasps (such as Diachasmimorpha tryoni and Diachasmimorpha longicaudata) are capable of hearing the larvae eating their way through the fruit. The wasp uses its ovipositor to inject an egg into the maggot. During the fly's pupation, the wasp larva will eat its host, killing the developing fly and emerging from the pupal case as an adult.
Many generalist predators of insects, such as ants, spiders, mantids, and assassin bugs will attack fruit flies. Birds, including chickens, will attack the larvae as they emerge from fruit, and some soil nematodes attack the larvae as the burrow and pupate.