Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
rizinbox
Posts: 134
Registered: 10-24-2010
My Carrier: du

Bluetooth Notification yes or no

Hi guys,

 

I am working on Bluetooth application. I write the code for bluetooth listening in background. From foreground to background notification I implement the GlobalEvent Handler.

 

My bluetooth listening code is inside of timer.

like

timer = new Timer();
			//timer.sc
			timer.schedule(new TimerTask() {

				public void run() {
					if(btPrompt==0)
					{
						startScanBluetoothDevices();
						btPrompt++;
					}
					
				}
			}, (5 * 60 * 1000), period);

 

And for controlling bluetooth listening start and stop I am using Global event and putting some condition for stop the thread.

 

And on the basis of condition I stop the Timer and Thread.

 

public void eventOccurred(long guid, int data0, int data1, Object object0,
			Object object1) {
		// TODO Auto-generated method stub
		if (guid == 0x7d3a74a5ccfe6483L) {
			
			bcSend = data0;
			bcCheck = data1;

			if (backGroundApp != null) {
				thestop();
				thestart();
			} else {
				firststart();
			}
		}
		else if(guid == 0x6d2a74a5ccfe6333L)
		{
			btPrompt = 0;
		}
	}
public void firststart() {
		if (bcSend == 2) {
			return;
		} else if (bcSend == 3) {
			return;
		}
		backGroundApp = new BlueToothListeningBackground();
		backGroundApp.start();
	}

	public void thestart() {
		if (bcSend == 2) {
			return;
		} else if (bcSend == 3) {
			return;
		}
		backGroundApp = new BlueToothListeningBackground();
		backGroundApp.start();
	}

	public void thestop() {
		
			backGroundApp.stopSearching();
			backGroundApp.stop();
		
	}

 

 

But problem is everytime when I come inside of app It give notification for on Bluetooth. But I already stop the timer and thread then i don't know why its calling again and again..

 

 

 

--
please mark posts as solved if you found a solution.
press the like button on the right side to thank the user that helped you.
------------------------------------------------------------
Riz
Please use plain text.
Developer
rizinbox
Posts: 134
Registered: 10-24-2010
My Carrier: du

Re: Bluetooth Notification yes or no

anyone ?

--
please mark posts as solved if you found a solution.
press the like button on the right side to thank the user that helped you.
------------------------------------------------------------
Riz
Please use plain text.