views:

57

answers:

2

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 globalEvent

ApplicationManager.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)
    {
        //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.

+2  A: 

you can use Runtime storage as a central location to share your data between background and UI thread.

Vivart
@Vivart:but is it not possible to exchange between them directly?
Sam Rudolph
@Vivart:Will this runtime storage require registration for test on simulator also?Pls reply its urgent?
Sam Rudolph
what registration? if you are asking about code signing, no code signing is not required for testing on simulator.
Vivart
The runtime store lets 2 applications share memory directly. On the BB, "processes" are really separate threads in the same JVM. You can share anything you want in the RT store.
seand
+1  A: 

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.

Michael Donohue
@Michael:Thanks for the reply,I have 1 more doubt.from UI Application I will post a GlobalEvent,and on this call Background Application will interact with server and will get the requested data,but at UI application,I want to proceed only after receiving of result from background application.How should I make UI Apllication dependent on background application.
Sam Rudolph
Send an event from the background app to the UI app. You will have to setup the UI app to wait for the event to be posted - use locks or polling. But that is a distinct question from cross-app communication.
Michael Donohue
@Michael: http://stackoverflow.com/questions/3911450/how-to-get-lock-of-one-application-for-other-in-blackberry Please help in my second doubt,it will be great help
Sam Rudolph
@Sam the link doesn't work
Michael Donohue
@Michael: sorry for inconvenience have uploaded here http://stackoverflow.com/questions/3918565/how-to-get-lock-of-one-application-for-other-in-blackberry
Sam Rudolph