On the initial load of our application, we make hundreds of worklight invokeProcedure calls, that take up to 20 minutes to an hour to fully complete. (Each one takes less than 10 seconds, so works fine.) However if the device lock screen comes up it pauses the application and if I don't respond quickly enough to the device lock screen, the worklight invokeProcedure gets interrupted and stops our initial load process.
Is there a way to configure the application on Windows, iOS, and Android to continue when the lock screen is showing?
You may want to look at a combination of preventing the screen lock from occurring and the background handling Idan Adar suggests, to provide a more graceful and controllable UX.
For iOS, setting the idelTimerDisabled property at the right places in your processing could prevent the screen lock, and then if other external device operations occur, you could gracefully complete and save process state of the rest of your procedure calls, resuming them when the app becomes active again.
[UIApplication sharedApplication].idleTimerDisabled = YES;
A similar approach should be supported in other platforms.
This is not a built-in functionality AFAIK.
For iOS, you need to enable "background fetch" mode:
https://www.ibm.com/developerworks/community/blogs/worklight/entry/ios_background_fetch?lang=en
For Android you may need to do this with a Cordova plug-in: IBM Worklight - How to use Worklight in a background process
As for Windows... no idea...
Related
I am running an accelerometer based android app that will run for a few months while phone is on and does nothing else. Some phone allow display not to go to sleep at all which allows my app run fine infinitely. The screen also has only a black display and nothing else apart from background accelerometer listener and occasional http posts. My question is if I remove the display screen while the app is running, would that stop the operating system and/or my app?
My question is if I remove the display screen while the app is running, would that stop the operating system and/or my app?
In short, it depends on your app architecture (otherwise i.e. music players would require to keep screen on to work). Depending on task you are really doing you may use Alarm Manager to periodically fire your code, or use Service.
because my questions might sound a bit suspicious, first some background: I'm writing an parental screen time control app. I am a seasoned java programmer with some Windows Phone background just learning the Android platform.
The app would run at startup (I understand that services can listen for a boot event and run) and when a violation of screen time is detected it would nuke all user processes that weren't around when the service started. Or lock the screen or some other annoyance every minute. No problems, right?
The kid will the try to terminate the process. I understand that this cannot be prevented on an unrooted device but a pair of processed could be used to bootstrap each other when the sibling dies?
Then the kid will try to uninstall the application, something that is also not possible on unrooted devices. I can listen to the uninstall event but by then the app is gone. Here is the tricky part, can I somehow reinstall automatically here? The application can ask any permission it wants on first install if it can help with the background reinstall
I understand that many of the features required here are nontrivial because that could be used for making, well, PITA apps. But I'm just trying to redistribute the misery my kids are giving me with screen control ;-)
Thankful for pointers,
A sadistic parent
you are looking for an Admin app.
this will allow you to put some restriction. and you can listen for event for deactivation where intern you can reset the device if necessary.
On the Android Market there is an app called Sleep Timer, and it is a type of alarm clock that brings runs the alarm even though you locked your phone while on facebook. I made a type of app that detects movement however it only works if the phone is left on that app... How can I make it work when the app wasn't left upfront, but is still running in the background?
You should take a look at Android Services, which provide the functionality you seek. Basically they enable you to create components that run in the background even when the user switch away from your application.
You can find a very good introduction to them here: http://developer.android.com/guide/components/services.html
I'm developing an app which requires the system to get the touch events even after the system goes to sleep mode or after the user locks the screen, I tried searching for a solution but it is hard to find one.
Should I want to set any permissions or is there any inbuilt methods or can I override any methods to perform this functionality.
I'm developing an app which requires the system to get the touch events even after the system goes to sleep mode or after the user locks the screen
Fortunately, this is not possible. Otherwise, the device would not be asleep, and battery life would suffer as a result.
Here is a link that shows how to prevent the phone from sleeping.
If you couple that with, say a black screen to 'pretend' the hone is sleeping but actually running your code. So your code can still intercept touch event
Then you need to install your app as a service and make it start when the device is turned on.
You will not need NDK or rooted device for that (sorry, got a short night :) )
I'm building a webapp for Android smartphones that runs with the OS internet browser. the main interface is to input data. the data is added to a queue (android 1.5: gears, android 2.x: html5). Each 5 minutes (using setTimeout), the script looks if an internet connection is active, and if so, sends all the queue to the server.
If the phone is plugged on the wall and the webpage is ontop, the timeout works. if the browser is minimized or another application runs on top of it, the timeout doesn't work. if the phone is in sleep mode it doesn't work either.
Can only native apps runs in background?
can only native apps runs in
background?
Certainly, I would not expect the browser to be waking up the device, for your sleep mode scenario. Apparently, based on your symptoms, they pause all Javascript threads when the browser itself is paused. That is not terribly shocking, given the battery problems that leaving those scripts running might cause.
You could also base it on system time, rather than just setTimeout. That way it would at least run when they returned focus to the browser.