Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Background listener to Global events

I found the sample code for this. How do I change it so it is always starts and always run in the background?

 

Here is the sample code I found (dont need the ack back but kept while testing)

 

package com.samples.eventFiring;

import net.rim.blackberry.api.mail.*;

import net.rim.blackberry.api.mail.event.*;

import net.rim.device.api.system.*;

import net.rim.device.api.ui.*;

import net.rim.device.api.ui.component.*;

import net.rim.device.api.ui.container.*;

class GlobalEventListening extends UiApplication implements GlobalEventListener

{

private MainScreen mainScreen;

public static void main(String args[])

{

GlobalEventListening theApp = new GlobalEventListening();

theApp.enterEventDispatcher();

}

public GlobalEventListening()

{

addGlobalEventListener(this);

}

public void eventOccurred( long guid, int data0, int data1, Object object0, Object object1)

{

if (guid == 0xba4b84944bb7429eL)

{

System.out.println("Event received, sending acknowledgment...");

ApplicationManager.getApplicationManager().postGlobalEvent(0x7d3a74a5ccfe6483L);

}

}

}

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Background listener to Global events

Set Project Property "Auto-start" to get it to always start.

 

You could change the UiApplication to just Application, mark it as a System Module, then you will never see it and there will be no icon. 

 

Is that what you want?

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Background listener to Global events

Basically yes,

 

thanks Peter.  Will test tomorrow

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.