We present a study of the prevalence of optical and radio nuclear activity with respect to the environment and interactions in a sample of the Sloan Digital Sky Survey (SDSS) galaxies. The aim is to determine the independent effects of distinct aspects of source environment on the triggering of different types of nuclear activity. We defined a local density parameter and a tidal force estimator and used a cluster richness estimator from the literature to trace different aspects of environment and interaction. The possible correlations between the environmental parameters were removed using a principal component analysis. By far, the strongest trend found for the active galactic nuclei (AGN) fractions, of all AGN types, is with galaxy mass. We therefore applied a stratified statistical method that takes into account the effect of possible confounding factors like the galaxy mass. We found that (at fixed mass) the prevalence of optical AGN is a factor of 2-3 lower in the densest environments, but increases by a factor of ~2 in the presence of strong one-on-one interactions. These effects are even more pronounced for star-forming nuclei. The importance of galaxy interactions decreases from star-forming nuclei to Seyferts to low-ionization nuclear emission-line regions to passive galaxies, in accordance with previous suggestions of an evolutionary time-sequence. The fraction of radio AGN increases very strongly (by nearly an order of magnitude) towards denser environments, and is also 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 star formation, 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.