12-29-2011 07:27 AM
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..
12-31-2011 05:18 AM
anyone ?