i need some help, can you explain to me how can i implement the Bluetooth Connection from my Application into my Mini Thermal Printer Device.
The scenario is like t
Narayan's answer needs a corrections. I believe the onStartCommand function should read.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("BT SERVICE", "SERVICE STARTED");
bluetoothIn = new Handler() {
public void handleMessage(android.os.Message msg) {
Log.d("DEBUG", "handleMessage");
if (msg.what == handlerState) { //if message is what we want
String readMessage = (String) msg.obj; // msg.arg1 = bytes from connect thread
recDataString.append(readMessage);//`enter code here`
Log.d("RECORDED", recDataString.toString());
// Do stuff here with your data, like adding it to the database
}
recDataString.delete(0, recDataString.length()); //clear all string data
}
};
btAdapter = BluetoothAdapter.getDefaultAdapter(); // get Bluetooth adapter
checkBTState();
return super.onStartCommand(intent, flags, startId);
}