I think there is a significant difference between your first and second 'THIS's, in that the second uses prefix-mode streams. (In prefix mode you have to send the length of the message first, as a four-byte integer, most significant byte first for 'bigendian', then the message itself.)
But I'm not clear whether the problem you are having is with pairing, connecting, or exchanging messages.
Does the tablet manage to pair with the HC-06? Try getting the tablet to forget the HC-06, then try to re-pair. If successful the HC-06 itself is probably OK
Does the LED on the HC-06 flash on-off-on-off...? It should come on permanently when it connects to some other BT device.
The Bluetooth code has a line commented out to initialise the async stream non-prefix mode. Try un-commenting it (and commenting out the line that initialises in prefix mode) and see if you get any further.