Hii, i need to make the bluetooth status visible in the app, i am using this Code
/** * ControlP5 ScrollableList * * replaces DropdownList and and ListBox. * List can be scrolled by dragging the list or using the scroll-wheel. * * by Andreas Schlegel, 2014 * www.sojamo.de/libraries/controlp5 * */ import android.content.Intent; import android.os.Bundle;
import ketai.net.bluetooth.*;
import ketai.ui.*;
import ketai.net.*;
import oscP5.*;
import controlP5.*;
import java.util.*;
KetaiBluetooth bt;
String info = "";
KetaiList klist;
ArrayList<String> devicesDiscovered = new ArrayList();
boolean isConfiguring = true;
int rectColFactor = 0;
//****************************************************************************
// The following code is required to enable bluetooth at startup.
//********************************************************************
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bt = new KetaiBluetooth(this);
}
void onActivityResult(int requestCode, int resultCode, Intent data) {
bt.onActivityResult(requestCode, resultCode, data);
}
//********************************************************************
void setup() {
size(displayWidth, displayHeight);
orientation(PORTRAIT);
background(30, 30, 30);
//start listening for BT connections
bt.start();
}
//****************************************************************************
void draw() {
enableBT();
getInfo();
}
//*************************************************************************
//**************************************************************************************
void enableBT(){
if (isConfiguring)
{
//-------------------- This stuff is for us to select the intended device
// ketai lib's UI list is used
ArrayList names;
//background(255, 0, 0);
klist = new KetaiList(this, bt.getPairedDeviceNames());
isConfiguring = false; // make the "configuring" status false as we have successfully configured
}
}
//**************************************************************************************
void getInfo(){
if (!isConfiguring)
{
//After configuration everything happens here
//first set a new background to say we are connecetd
background(255, 255, 0);
}
}
//*************************************************************************************
//****************************************************************************************************************************
//---------------------- For killing the list after you've selected a device to pair
void onKetaiListSelection(KetaiList klist) {
String selection = klist.getSelection();
bt.connectToDeviceByName(selection);
//dispose of list for now
klist = null;
}
//------------------------ Call back method to manage data received
void onBluetoothDataEvent(String who, byte[] data) {
if (isConfiguring) {
return;
}
//received
info = new String(data);
rectColFactor = Integer.parseInt(info);
}
//******************************************************************************
i tried with an If statment or boolean function in the void enableBT() Function, in the getInfo(), and in the void onKetaiList Selection function, by drawing a red or green ellipse , but i have always same result , if i am connected or not,
does anyone have an idea?