how to exchange data between two Blackberry Applications?
To exchange data between apps I have created 2 applications, one is a UI application and the other is a background application, by setting an alternate entrypoint
I was able to find a similar question but was not able get the help I need there I am able to create Global Events and a Global Listener, but my problem is how to transfer Data from one application to another. In UI APPLICATION we can post globalEventApplicationManager.getApplicationManager().postGlobalEvent(0xba4b84944bb7);
In Background Application we can Listen and send the Acknowledgement
public void eventOccurred( long guid, int data0, int data1, Object object0, Object object1)
{开发者_如何学Python
//Is this the GlobalEvent we are waiting for?
//Long = com.samples.globalEventFiring.GlobalEventListening
if (guid == 0x7d3a74a5ccfe6483L)
{
//Yes it is.
System.out.println("Acknowledgement received.");
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Dialog.alert("Event was fired and acknowledged.");
}
});
}
}
But how to transfer data from background application to ui application.How UI application can access data or objects of background application.
you can use Runtime storage as a central location to share your data between background and UI thread.
You can use the int and Object arguments in the event system to pass data between the application instances. When posting the event, use the postGlobalEvent overload that takes ints and Objects. And in the event handler, downcast object0 or object1 as necessary.
精彩评论