Why doesn't the service work all the time in the background when the screen is off + USB not connected?
Using Qt, I created a test android service that uses QTimer to issues Push-notifications every 5-seconds. I did this to monitor whether the service will be always running in the background.
However, after turning the screen off, I get the notifications for around 30 seconds(total:5 or 6), then I get nothing for like 2-3 minutes. Then I get one notification after. Then I get nothing again.
I tried all of the following with no solution:
*return START_STICKY_COMPATIBILITY;
*return START_STICKY;
*Using Power Manager:
powerManager = (PowerManager)m_instance.getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wakeLock.acquire();
Manifest:
<uses-permission android:name="android.permission.WAKE_LOCK"/>
Btw, the service is not killed, as once i turn Back-On the screen, it resumes.
Why doesn't the service work all the time in the background when the screen is off + USB not connected?