Both the radio spectrum features such as power spectral density (PSD) and the communication performance such as packet loss rate (PLR) can be exploited to detect jamming attacks, with the resulting detection results used to enhance the reliability of wireless communications. In this paper, we propose a reinforcement learning (RL)-based jamming detection scheme based on the channel energy, the received signal strength indicator of each packet, the channel gains, PLR and transmission latency of mobile devices, in which the test threshold and the number of PSD bins are optimized by access point to enhance the utility as a weighted function of the detection speed and accuracy. The detection results are exploited for mobile devices to choose the transmit power and channel to reduce the PLR and transmission latency. Experimental results based on the universal software radio peripheral and Raspberry Pi to detect four jamming types including constant, sweeping, random and smart jamming show that our proposed schemes improve the detection accuracy and speed, as well as the communication performance.