How can I programmatically wake up android device in Doze mode for running background processes - background

I have an application that runs in the background on Android device. The application performs certain tasks which are scheduled from a control panel. Normally the tasks are performed when requested. However many times the device goes into Doze mode and the tasks are never executed.
I have tried using the PowerManager feature called wake-locks but the system ignores the wake-locks.
Doze Restrictions
Is there a way to programmatically disable Doze Mode for processing background tasks of this app but keep the screen off?

Related

How does apps like Whatsapp or telegram listen to the incoming call/message events on Android?

I built a VoIP calling app which maintains a persistent connection with the server to listen to any incoming calls. I implemented a background service to do this.
But since Oreo, this running code is now broken because of the introduction of Background Execution Limits
After looking into forums, I found that some people are suggesting
Convert Service to JobService and let android schedule it
Doing so, my app won't be able to receive calls when it is stopped
Run your operations in foreground services
It is annoying for some users to see a constant notification in the notification bar. So these above-mentioned options aren't working for me to fix my code for Oreo.
How does WhatsApp get the incoming (VOIP) call in Android (Oreo onwards) working around the Background Execution Limits?
(Sticky) foreground services are not affected by the restrictions. So you could use one those as replacement for background services on Oreo.
But foreground services have two disadvantages: They are less likely killed by the system in order to reclaim resources compared to background services, and hence affects the Android system's self-healing capability. And they require you to display a permanent notification. But Users are able to suppress the notification, somewhat mitigating this disadvantage.
I am assuming that you are using SIP to establish the connection and initiate calls. Without a service constantly re-sending REGISTERs, the app doesn't receive INVITEs when the server sends them.
A workaround for this problem is what is called the "push notification strategy". It works as follows, when the server sends a INVITE, it also sends an FCM notification to your app, This wakes up your app which then sends a REGISTER to your server, which in return forks the call to your app. Here is a video that better explains this strategy
There are two options:
use platform push services (APNS or FCM)
maintain persistent socket connection and exclude application from battery optimisations.

Windows Phone 8.1 : UDP packets stop being transmitted when phone app is in background

Background Info
I downloaded the Thread Pool Sample for Windows Phone 8.1 (C++) and modified it so that the periodic timer sends UDP packets to a remote IP on a regular interval.
Problem
I noticed the following:
The UDP packets are sent out regularly when the app is launched from MSVS 2013 regardless of what you do on the phone
The UDP packets stop being sent out when the app is launched from the phone's program list when the app is put in background.
Question
How do you create a periodic task on Windows Phone 8.1 which runs every 10 seconds? The periodic task must send out a UDP packet to a pre-defined IP:PORT address regardless of what the user is doing on the phone.
I had a look at this one:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977059.aspx
but I don't see the possibility of having the timed task run every 10 seconds.
How to reproduce the problem
Link To Test Project
The test project includes instructions on how to reproduce the problem that I've described.
Unfortunately, what you're after is not possible on Windows Phone. Once the application is no longer active on the phone, it is tombstoned and no longer runs.
You can achieve something similar with Background Agents, but they are restricted in what they can do and they only run every 30 minutes.
There are other background agents that respond to different phone events, including location changes, network availability changes and geofencing triggers.
There's a slightly hacky method available to force a background tasks, and that's to impersonate an audio player task. It's not a great solution though.

Check if process is running with VB.NET (Compact Framework 2.0)

I am working on an (console) application, which should be executed on startup and keeps running all the time in the background (executing something every 30 minutes).
How can I, in another (device) application, check if my console application is running (and start it if its not)?I am using VB.NET CF 2.0 and everything is being deployed on a device running WM 6.5
All the code examples I found where only available on the "standard" .NET.
There are several ways your "monitoring" app could work (and certainly more than I list here).
Use a named mutex (you'll have to P/Invoke it). The monitored app would create and hold it, and the monitoring app would periodically check to make sure it's held. If it's not held, the monitored app is no longer running.
Use the Toolhelp APIs. Have the monitoring app use the Toolhelp APIs to periodically enumerate the running processes. If the monitored app is not in the process list, it is not running.
Use a named event. The monitored app would have a background thread that periodically sets a named (watchdog) event. The monitoring app would wait on that event and if it fails to get the event in a certain time bound, the other app is either not running or has locked up.
Use a socket. Have the monitored app open a socket and listen on it. The monitor app would send a "ping" periodically to the monitored app. The monitored app would respond to the ping with an ack. If the monitoring app doesn't get an ack, the monitored app is either not running or is locked up
Use a window handle. The monitor app periodically P/Invokes GetWindow of FindWindow to find an always-present window in the monitored app - often by Form text. If the monitoring app can't find the Window, the monitored app is not running.

Can iPhone app which runs in background send data over network to a remote server?

This application is location awareness app. It uses GPS details so it can be run in background. But is it possible to send the collected data to a remote server while the app is in background? or maybe when the screen is locked?
For Required background modes add App registers for location updates in plist, this will make application work in background and you can send location updates to server.
Here consider that your location services are not continuously on, else it will drain complete battery of device.
Hope this help you..

Windows Phone local database changes listener

I am new to windows phone development and facing an issue. I want my application to act like a listener to any changes being made in local DB. If application is running and any change is made in the DB (e.g by background agent) then the foreground application should be notified right away.
Is there any way I could register some kind of event in my foreground application which is triggered when there is any change in the local DB?