Flex - Run Air Application In Background - actionscript-3

I am trying to provide my users with the option to have my application launch automatically and complete a task at a certain time every week.
I can make my application launch at log in using NativeApplication.nativeApplication.startAtLogin=true but I then want to detect if the time is the time they selected and if it isn't then run the application in the background until the time does match or the user shuts down their computer.
Does anyone know of a way to do this? On Adobe's webpage comparing Flex web apps and desktop apps it implied to me that applications could be run in the background but I'm struggling to find anything.

You can close the initial native window without killing the process
NativeApplication.nativeApplication.autoExit = false;
NativeWindow(this.stage.nativeWindow).close();
OR
You can close the initial native window and create a new window that acts as a desktop widget without appearing in the taskbar with either the UTILITY or LIGHTWEIGHT window type.
http://help.adobe.com/en_US/air/reference/html/flash/display/NativeWindowInitOptions.html#type

Either you keep the process running which times when the next 'job' should be ran, or you can set a system cron job (or something similar) which is specific to the OS. You'll want to use the NativeWindow option of 'LIGHTWEIGHT' so that your application doesn't show up to the user.
Personally, for these kinds of processes, I don't even try to use Air since it isn't really made for this kind of stuff. It's meant to be used for UI based apps and not process based. Use Java or C# instead.

Related

Long-running task performed in foreground is suspended when app goes to background

When a user first opens my app, I need to download and install some content from a server before they can begin using the app. The problem is that this takes around 5 minutes on wifi, during which time the app goes into the background and the download is suspended.
Is there any way to either:
Prevent an windows app from entering the background while I perform my download
or continue peforming the task in the background (i.e. perform the task irrespective of whether the app is in the foreground or background)
Also, I don't want to use the BackgroundDownloadManager
Thanks
When the app is being suspended, all processes are stopped and and background task cancelled. Your last chance to do something is Suspending event - see more at MSDN.
In your case, when you need to download big file in the background - the mentioned BackgroundDownloader would be the best option - it's designed for such tasks. In other cases you will have to convince user to leave the app in the foreground (a message?), also take care about lockscreen (see DisplayRequest class).
I'm not also sure but maybe you will be able to use BackgroundTask (separate process), triggered with MaintanceTrigger - but then user will be able to download the file only in specific circumstances and probably not right away.

How can I tell if a Chrome app is already running

I'm looking for means of telling whether other instances of a Chrome app are already running but Chrome's excellent context isolation makes it quite difficult.
Also, I was hoping chrome.runtime APIs would help but it doesn't seem to be the case.
Essentially, I want to make sure only one instance can run at any given time.
Thanks!
Your background page can store global state that lets you keep track of which windows have been launched by the app.
Your app can only have one background (or event) page at a time.
If you are wanting to prevent multiple windows from launching, make sure your chrome.app.window.create call has an "id" option. That means only one window will be created with that given id.

Run Windows Phone App in background without UI

I am developing a Windows phone 8 app that need to run only in background with UI. Is there any way I can run the app in the background, or without actually being open?
It depends upon what you want to do in the background. Generally speaking you can't implement something like a Windows service that will startup automatically when the phone is launched.
That said you can run your app in the background within given limitations. Check out MSDN for detailed information.
Why all these limitations you might ask yourself? It's to provide a good battery life to the user.
Edit:
For the periodic agent to start running the app must be started once. Further the agent must update a live tile (user must pin it to the start screen) or the app has to be once opened every 14 days.
Another option might be using push notifications to trigger an update..

How can I pre-start my RAP application to trigger warmup right after startup

I have a RAP application which we deploy into a Tomcat instance. The application does some additional stuff during it's first startup.
Currently when the first user opens the webpage in a Browser, it takes quite a while until the application is ready because of this one-time initialization work.
This is bad for usability as the first user needs to wait a long time until this startup-work is done.
Is there a way to trigger or simulate a first session after the Tomcat is started so we can warmup the application and the first user receives feedback quickly?
I tried to do some simple URL-requests via URLConnection to simulate a browser, but it seems the protocol to trigger a new session is non-trivial.
I also tried to use HtmlUnit to request the page with JavaScript enabled, this works to some degree, but HtmlUnit is quite heavy for this simple step.
So is there an official API or at least some sort of workaround that allows me to pre-start and initialize the application?
Unless this initialization requires a UI session (i.e. a user), the configure method of your ApplicationConfiguration could be a suitable place. However, at this point, the ApplicationContext has not been completely set up, so it could be too early. Also, if your application is based on the workbench and extension points, you won't have an ApplicationConfiguration of your own.
Would you mind opening a bug report (http://eclipse.org/rap/bugs) and describe your use case? I think we should provide some kind of hook for applications to setup and clean up, e.g. an ApplicationContextListener?

Win32: Is it possible to build an app that houses other apps?

I was wondering, how would you go about writing an application that basically houses other applications inside of it?
The reason I ask is that I'd love to build an app that 'conquers' my current explosion of open windows. I've used virtual window managers before and they're nice and all, but I could do so many things with an app like I mention.
Alternatively does anyone know of an easy to use/intuitive application for confining windows to 'regions' of your screen? Something like GridMove, but more intuitive and less flakey?
You could create a window, then you could enumerate all Windows that have the style WS_OVERLAPPEDWINDOW, select the ones belonging to the application you want to house, then call SetParent on the window, setting the parent to the window you created. You could also use FindWindow to find a window by its title.
All the windows inside the house can never leave the house window's boundaries, but they still follow all the same rules. You can still click-and-drag windows etc.
The problem here is that if the application inside the house creates another window, its parent will most likely be the desktop window, not the house window.
I think what you are describing is generally called a Window Manager. The Windows shell is itself a (poor) example of a window manager. You might want to investigate some alternatives. I know there has been some success in getting KDE ported to Windows, so you might want to look at the current state of that project.
Microsoft also provides a PowerToy (IIRC) that gives you virtual desktop support, but it's really bad. Have you considered just getting a second monitor (and perhaps a utility such as MultiMon Taskbar to get a second task bar on the other monitor)?
Here is code that uses FindWindow / SetParent to create a tabbed view combining different applications Jedi Window Dock
I also wrote an application (not free, not open source) that takes this idea a bit further called WindowTabs.
The only caution I would give you is that not all applications like being parented. If your writing .NET, there are some "Gotcha's" there (which is why WindowTabs doesn't use parenting).
Also, in general, once you do a SetParent, you are joining the threads at a Win32 level meaning that if one hangs, all of them are toast.
Multiple Document Interfaces could help you out.
Despite the multiple down votes, I stand by this answer because the OP never stated the source of the "explosion of windows." I've seen business apps that open several windows at a time (or users that would open several instances "to save time") where MDI would've been a nice feature for them.
If the OP is a power user who has a need for another window manager because he runs many apps at once, then this really doesn't apply. It also isn't the problem I'd be addressing -- it would be finding a way to have fewer windows.
In general, there's always a VM.
It may be overkill or it may not work depending on the specifics of what you're trying to do. But VMWare will let you copy/paste files and text between your VM and local machine, so it's not that far off of being a true window manager. The system requirements aren't even that outrageous, considering how much memory iTunes + a typical browser eat up.