问题
I have a requirement to have a background process using Application, while also having a UiApplication through an alternative entry point.
Now, everything works great and I'm able to communicate between them fine, apart from when it comes to telling the UiApplication to close from the background process.
I've tried a number of methods:
UiApplication.getUiApplication().requestClose()
doesn't work.
I've tried setting a boolean value to true, which the UiApplication checks every second to see if it's true or not, if so, it closes itself. Doesn't work...
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run(){
System.exit(0);
}
});
Anyone have experience in this who can point me in the right direction?
回答1:
Background and Foreground are different processes and they aren't sharing data memory. So basically you can't set any boolean in one app and just check it in another.
But since you have communication between two apps already, probably using ApplicationManager.postGlobalEvent()
, you can add another event "Exit".
来源:https://stackoverflow.com/questions/13528367/blackberry-closing-uiapplication-alternative-entry-point