Double click on Cordova mobile app to go to background mood instead of single click

Viewed 24

I have an Cordova android mobile app installed on Android version 12 in which I want my app to go to background mood when I click on back button or I click on home button. For this purpose I used Cordova plugin Cordova-plugin-background-mode and used this in the following way.

enter image description here

then added the permission in manifest file like given below.

enter image description here

after that using command cordova build android it generate the apk .

After installing APK in mobile it gives my desire functionality like if I change to another app and came back to the 1st app again it continues from where I left it.

Problem is double click

for example if I want to go back or go to home screen I have to press two time quickly then it goes to background mood. it does not work on single click on back button or home button.

if I remove the permission android.permission.FOREGROUND_SERVICE from the manifest file then app start working on single click but in this case app don't go to background mood rather app is destroyed and when I came back to app again it start from the zero.

I am new to Cordova and I have searched a lot but could not find solution. Need any kind of help regarding my issue.

Thanks in advance.

0 Answers
Related