We present a study of the prevalence of optical and radio nuclear activity with respect to the environment and interactions in a sample of SDSS galaxies. We defined a local density parameter and a tidal forces estimator and used a cluster richness estimator from the literature. The possible correlations between these parameters were removed using a principal component analysis. We applied a stratified statistical method that takes into account the effect of possible confounding factors like the galaxy mass. We found that the prevalence of optical AGN is a factor 2-3 lower in the densest environments, but increases by a factor of ~2 in the presence of strong one-on-one interactions. The importance of galaxy interactions decreases from star-forming nuclei (SFN) to Seyferts to LINERs to passive galaxies, in accordance with previous suggestions of an evolutionary time-sequence. The fraction of radio AGN increases strongly towards denser environments, and is enhanced by galaxy interactions. Overall, the results agree with a scenario in which the mechanisms of accretion into the black hole are determined by the presence and nature of a supply of gas, which in turn is controlled by the local density of galaxies and their interactions. A plentiful cold gas supply is required to trigger SFN, optical AGN and radiatively-efficient radio AGN. This is less common in the cold-gas-poor environments of groups and clusters, but is enhanced by one-on-one interactions which result in the flow of gas into nuclear regions; these two factors compete against each other. In the denser environments where cold gas is rare, cooling hot gas can supply the nucleus at a sufficient rate to fuel low-luminosity radiatively-inefficient radio AGN. However, the increased prevalence of these AGN in interacting galaxies suggests that this is not the only mechanism by which radiatively-inefficient AGN can be triggered.