As an important part of an intelligent photoelectric system, ultraviolet detector has been widely used in many fields in recent years. The research on self-powered heterojunction photodiode is particularly important. In this work, a dual-mode self-powered GaN/(BA)
2PbI
4 heterojunction ultraviolet photodiode is prepared and discussed. The GaN film is deposited on sapphire by metal-organic chemical vapor deposition, and then the (BA)
2PbI
4 film is spin-coated onto the surface of the GaN film to construct a planar heterojunction detector. The X-ray diffraction, energy-dispersive X-ray spectroscopy mapping and scanning electron microscope measurements are used to determine the quality of GaN and (BA)
2PbI
4 thin films. When the film is illuminated by 365 nm light with a power density of 421 μW/cm
2 at 5 V bias, the responsiveness (
R) and external quantum efficiency (EQE) are 60 mA/W and 20%, respectively. In self-powered mode, the rise time (
τr) and decay time (
τd) are 0.12 s and 0.13 s, respectively, illustrating the fast photogeneration process and recombination process for photo-excited electron-hole pairs. And, the
R is 1.96×10
–4 mA/W, owing to the development of space charge region across the interface of GaN thin film and (BA)
2PbI
4 thin film. The outcomes of this study unequivocally demonstrate the extensive potential and wide-ranging applicability of self-powered UV photodiodes based on the GaN/(BA)
2PbI
4 heterojunction configuration. Moreover, this research presents a new concept that provides a novel avenue to the ongoing development of intelligent optoelectronic systems.