MagTek BulleT User Manual

Page 11

Advertising
background image

Development


else

{

//Handle Error and Return

}


}

private

boolean

IsCompleteMessage(String lpstrData)

{

try

{

if

(lpstrData.length() > 0)

{

if

(Character.toString(

'\r'

).compareTo(

Character.toString(lpstrData

.charAt(lpstrData.length() - 1))) == 0)

{

return

true

;

}

}

}

catch

(Exception ex)

{


}

return

false

;

}

Add Code to BluetoothChat.java

// The Handler that gets information back from the BluetoothChatService

private

final

Handler

mHandler

=

new

Handler() {

case

MESSAGE_READ

:

byte

[] readBuf = (

byte

[]) msg.

obj

;

// construct a string from the valid bytes in the buffer

String readMessage =

new

String(readBuf, 0, msg.

arg1

);

if

(readMessage.length() > 0)

{

mStringCardDataBuffer

+= readMessage;

if

(IsCompleteMessage(

mStringCardDataBuffer

))

{

processCardData

(

mStringCardDataBuffer

);

mStringCardDataBuffer

=

""

;

}

//


}

break

;

Advertising