BlackBerry 10 Cascades. How do I make a long running headless app terminate itself? - qt

I'm making a BB10 app with a headless component that's normally supposed to run nonstop, except when a certain field in its QSettings changes (to save battery power).
I tried looking everywhere for the documentation. But I still can't find out how to make a headless app terminate itself.

You can get notified every time your settings file change using QFileSystemWatcher and calling bb::Application::instance()->quit() when a certain QSettings value changes. Here's an example from BlackBerry that uses QFileSystemWatcher in headless to get notification whenever the QSettings file changes.
I prefer using invocation or my own headless communication mechanism though, you can see an exemple of how I usually deals with terminating the headless app here.

Related

Manually saving scene NSUserActivity on iOS/iPadOS 13

I have implemented iOS/iPadOS 13 state restoration using NSUserActivity, mainly because my app supports multiple scenes.
The problem is that when I'm running the Simulator with two side-by-side scenes and force restart the app by rebuilding the activities are not saved and the UI is not properly restored on relaunch.
On the other hand if I first go back to the iPad home screen and then I force relaunch the app, the activities are properly restored.
Would this mean that a crash of my app would prevent saving these activities leading to an inconsistent UI state on relaunch?
And how could I periodically "force" saving activities (get stateRestorationActivity(for scene:) called)?
The problem is that when I'm running the Simulator with two side-by-side scenes and force restart the app by rebuilding the activities are not saved and the UI is not properly restored on relaunch.
What you're seeing when you "force restart the app by rebuilding" is the expected behavior. When you force restart like that, the app does not have a chance to save your NSUserActivities. Per Apple's state restoration tutorial:
If you want to test your app’s ability to restore its state, do not use the app switcher to kill the the app during debugging. Instead, use Xcode to kill the app, or kill the app programmatically. One technique is to suspend your app using the Home button, and then stop the debugger in Xcode. When you launch the app again using Xcode, UIKit initiates the state restoration process.
I understand that you weren't killing the app in the switcher, but any "forced" stop will disable state restoration (with a caveat). To test state restoration, instead use the technique suggested by Apple's tutorial above.
Would this mean that a crash of my app would prevent saving these activities leading to an inconsistent UI state on relaunch?
I think so. This is the caveat from earlier. While Apple says that killing the app (whether in the app switcher or from a crash or whatever) will disable state restoration, this is not necessarily true. You can see for yourself that Apple's own apps have odd state restoration inconsistencies when killed in the app switcher and re-opened (you may have to try it a few times to get inconsistent behavior). While I haven't tested this, I'd imagine that those same inconsistencies can occur from app crashes.

chromium profile directory is already/used by another BrowserContext instance or process

I used an evaluated jxbrowser, which version is 6.14, I write an demo to use it. but i have a problem with it.
Use the demo app to start an application, which can show web UI, keep this applciation with opened, but then I start demo app again, system will throw below exception:
chromium profile directory is already/used by another BrowserContext instance or process
jxbrwowser cannot start two clients in one PC? if can, how to resolve it?
We strongly recommend that you don't use several BrowserContext instances with the same profile directory. Chromium engine wasn't designed for such usage and doesn't support it. Even if you don't see any issues right now, the issues will appear later in end user environments. For example, in macOS environment you will get the Chromium's error message dialog every time when you run your application instance developed in such way.
Since it's a critical requirement in the Chromium engine, I don't think we will make it configurable in next versions. This is how Chromium engine works. These is a recommendation we have to follow when working with the Chromium engine.

Turn on GPS when App starts in QT

So I was working on a positioning app which needs GPS to be turned on. So I wanted a way to automatically turn on GPS in the background, if even possible with high accuracy or atleast have a popup window come up so the user can turn on the GPS right away. But sadly I couldn't find a single way to do so in QT, if there is a solution it's always written in Java. Can I somehow do it in QT too or import Java code in it?
Would I also be able to keep my GPS updates running in the background? Because as soon as I press the home button the updates stop to come up in the console with qDebug... or is it just the qDebug function that can't run when the app is not open?
Will I be able to use GPS in my Qt app?
First, check if the target platform has GPS and/or capable of resolving geo-coordinates. Next check the manual out: Qt Location. Mind that they refer to this functionality as 'location' so it maybe partially available even without actual GPS unit on device if there is another provider type (I guess partially and not for all platforms). I could only find this list of platforms supported:
Qt Location Classes for accessing GPS and other location services and
for mapping and navigation. Split off from the Qt 4 Mobility module of
Qt Location. Supported on Android, BlackBerry, iOS, Linux (using
GeoClue), Windows and Sailfish OS.
As for starting the GPS (location services provider) there is such entry for QML for sure called start() of PositionSource. It also implies one can find the same functionality in C++ as well.
Would I also be able to keep my GPS updates running in the background? Because as soon as I press the home button the updates stop to come up in the console with qDebug... or is it just the qDebug function that can't run when the app is not open?
Home button: it implies Android? Unclear what you ask but the Android app lifecycle is a bit different matter than that. The GPS will be working independently of your app but will the app respond to messages is more determined by Android.

How to respond to desktop startup notification with Qt

I have a Qt application, running under Xfce and other Linux desktops, which works well, except that the circulating "startup notification" icon is not dismissed when the app starts up, so that it persists for some time after the app main window is showing and complete.
I would assume that either the QApplication would by default dismiss the notification when the main window event loop starts, or I would call some method to do so. I can't find anything relevant in the Qt API documentation, or with google searches on Qt startup notification.
How can one dismiss the startup notification, in a Qt application.
Doesn't adding of
StartupNotify=false
to the .desktop file of your app solve the problem?.In KDE,
X-KDE-StartupNotify=false
works; perhaps XFCE has a similar variable.
The startup notification is sent automatically inside Qt when the first window is first shown (see src/plugins/platforms/xcb/qxcbscreen.cpp), but obviously, due to a bug, it does not work if there are quotes or the escape character (\) in the .desktop file in the path to the program.
In addition, if Terminal=true is presented, the environment variable DESKTOP_STARTUP_ID is deleted by xterm and does not reach your application, so it is better not to enable both Terminal and StartupNotify flags at the same time.
Was tested on MATE.

How does Adobe CONNECTNOW load and run acaddin?

I am looking for options to download, Install and run a custom plugin/add-on(an exe or an installer) from my Flash Movie similar to how the connectnow does that?
When we initiate the screen sharing for the first time, connectnow prompts us for mandatory add-in by showing the message "To use this application, you need the Adobe ConnectNow Add-in.Would you like to install it now?". Once we agree, it downloads and installs acaddin.exe at the location %USERPROFILE%\Application Data\Macromedia\Flash Player\www.macromedia.com\bin\acaddin on our local machine. Then automatically launches the acaddin.exe and allows the user to close the browser window from where the acaddin.exe was launched.
From the next time onwards, when we login to connectnow, it launches the exe directly.
In this context:
If I were to load my own exe/add-in from flash, How can I acheive that?
How does connectnow application/flash determine whether an add-in was already installed or not?
Connect, and I assume ConnectNow, use hidden, undocumented, private APIs for much of their functionality.
You will not be able to do this.
The best you can hope for is to pass the location of your executable to the browser as a local URL and let the browser handle it. I assume in most cases the browser will reject its' execution. Can you imagine the potential for abuse of such a feature?
Instead of using a browser based app, you may want to investigate using AIR and Native Process.

Resources