The best option for you is the WakeLock api
Add permission to manifest file for wakeLock
<uses-permission android:name="android.permission.WAKE_LOCK" />
then you can add the following according to your changes, as shown in the MDN behavior
function forPingTimer(){ var lock = window.navigator.requestWakeLock('screen');
and release the lock using the lock.unlock(); function lock.unlock(); .
OR
For the cordova application, you can also use the insomnia plugin . The changes that must be made to the config file are specified in the documents and you can simply use it as follows:
function forPingTimer(){
source share