An antenna device, applied to an electronic device and the antenna device includes: an antenna unit, configured to transmit and receive signals; a rotation unit, connected to the antenna unit, and configured to rotate the antenna unit when the electronic device is powered on, record a signal strength in preset angle for each rotation and generate an angle and signal strength mapping table, and further configured to rotate the antenna unit to a position with a strongest signal according to the angle and signal strength mapping table, which realizes automatic adjustment of antenna direction to optimize antenna performance.