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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Regular Contributor
Posts: 95
Registered: ‎07-16-2010
My Device: 8520
My Carrier: bsnl
Accepted Solution

sendListener(sms) and folder listner invalk multiple times

i implement net.rim.blackberry.api.mail.event.FolderListener and net.rim.blackberry.api.sms.SendListener

 

toghether in my application

 

its work fine on simmulater

 

but when i test on device both called multitimes in that

 

i start both listner in aftre app start with internet

 

device 8520 os5.0 with wifi and EDGE

 

please any help for that how can i fix so its called once?

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: sendListener(sms) and folder listner invalk multiple times

where do you register the listener? in an autostart part or on every startup?
do you de-register the listeners when you exit your app?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 95
Registered: ‎07-16-2010
My Device: 8520
My Carrier: bsnl

Re: sendListener(sms) and folder listner invalk multiple times

hey simon thanks for replay

app start on auto start and background app
i register listner in application startup for that i also implement SystemListener

and i dont deregister listner anywhere...!

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: sendListener(sms) and folder listener invoked multiple times

It does sound like your listeners are being started mulitple times as Simon said. 

 

Listeners like this are removed automatically by the system only on a cold restart, so if you want to make sure you only do this once, then that is the place to register the listeners.

 

Alternatively, I would save a flag in RuntimeStore.  Then you can check this flag to see if you need to register your listener.  RuntimeStore is cleared on a battery out reset.  Then you can do it at application start-up.

Regular Contributor
Posts: 95
Registered: ‎07-16-2010
My Device: 8520
My Carrier: bsnl

Re: sendListener(sms) and folder listener invoked multiple times

sorry for late replay ...!

 

my app formay

 

class NewTestApp extends Application implements SystemListener 
{
	public static void main(String [] args) 
	{
		NewTestApp appInstance = new NewTestApp();
		if (ApplicationManager.getApplicationManager().inStartup()) 
			appInstance.addSystemListener(appInstance);
		else 
			appInstance.doStartupWorkLater();
		appInstance.enterEventDispatcher();
	}
	private void doStartupWorkLater() 
	{
		invokeLater(new Runnable() 
		{
			public void run() 
			{
				doStartupWork();
			}
		});
	}
	private void doStartupWork() 
	{
		new Thread(new Runnable() 
		{
			public void run() 
			{
				try 
				{
					Application appInstance = Application.getApplication();
					//....
					//assign listner
					//....
				} 
				catch (Exception e) 
					System.out.println("==========error===="+e);
			}
		}).start();		
	}
	public void powerUp()
	{
		removeSystemListener(this);
		doStartupWork();
		}
	public void batteryGood(){}
	public void batteryLow() {}
	public void batteryStatusChange(int arg0){}
	public void powerOff() {}
}

 now in that things is possible multiple assign listner??

and when i cold reset blackberry do startup work run again?

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: sendListener(sms) and folder listener invoked multiple times

powerUp is called after a "soft restart", which does not remove any listeners. this means you add them again.

your doStartupWorkLater also looks strange, please check if you changed the code from whereever you took it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: sendListener(sms) and folder listener invoked multiple times

This logic will run every time you application is started.

 

If you are trying to set up listeners to run only once, then you normally set up an alternate entry point, and have the same code that you have below, in there.  Here is a KB article regarding an alternate entry point:

http://supportforums.blackberry.com/t5/Java-Development/Set-up-an-alternate-entry-point-for-an-appli...

 

Do you need your listeners running al the time, or only when your your user starts your application?