Olá amigos, estou com grandes problemas,
Tenho um Defy+ e um impressora ZEBRA TLP2844 preciso apenas dar um “alo impressora no papel dela”
Criei um projeto e colei o codigo, agora ele acha a impressora fica até ON:
agora só precisaria mesmo imprimir vou colocar meu código e se puderem ajudar agradeço,
pois estou precisando muito.
Obrigado.
public void onClick(View v) {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
MensagemAlerta("Erro", "Dispositivo não possui bluetooth");
} else {
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
ArrayList<String> impressoras = new ArrayList<String>();
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, impressoras);
if (pairedDevices.size() > 0) { // Verifica se tem algum dispositivo pareado
// Monta uma array com os dispositivos que estiverem pareados...
for (BluetoothDevice device : pairedDevices) {
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
// Carrega a lista com os dispositivos encontrados
mView = (ListView) findViewById(R.id.lista);
mView.setAdapter(mArrayAdapter);
// Precisa pegar o MAC Address na mArrayAdapter
String address = "00:02:72:E3:8E:57";
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
// UUID é um identificador universal usados nos dispositivos bluetooth com 128 bits
// serve apenas para evitar conflito na hora de comunicar com os dispositivos
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
try {
mBluetoothSocket = device.createRfcommSocketToServiceRecord(uuid);
mBluetoothSocket.connect();
in = mBluetoothSocket.getInputStream();
out = mBluetoothSocket.getOutputStream();
[b]
/***************************************************************
*
*
*
* Ate aqqui o Led da impressora esta on (isso qure dizer )
* acho que conectou
* Pergunta: Como eu faco para dar um COMANDO ESC/POS ou um System.ou.println("ALO IMPRESSORA "):
****************************************************************/
[/b]
} catch (IOException erro){
MensagemAlerta("Erro", "Não foi conectar com o dispositivo." + erro);
}
}
}
});