PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Imprimer en bluetooth
Imprimer en bluetooth
Débuté par Nico, 23 fév. 2016 19:44 - 6 réponses
Posté le 23 février 2016 - 19:44
Bonsoir,

un client a acquis une imprimante Bluetooth Zebra ZQ110.

Je galère car il faut gérer l'impression avec du code java et je ne suis pas un spécialiste.

Voici l'erreur de compilation que j'ai lorsque je veux générer mon apk :

Echec de la création de l'application Android <D:\Windev Mobile\GreenEcoPass\Exe\GreenEcoPass.apk>.

Ligne de commande : "C:\Program Files\Java\jdk1.8.0_65\bin\java.exe" "-Dorg.gradle.appname=D:\Windev Mobile\GreenEcoPass\Android\Generation" -classpath "C:\gradle-2.2\lib\gradle-launcher-2.2.jar" org.gradle.launcher.GradleMain assembleDebug -b build.gradle

Erreur retournée :
D:\Windev Mobile\GreenEcoPass\Android\Generation\src\com\secutech\greenecopass\wdgen\GWDCPCOL_Zebra.java:33: error: non-static variable this cannot be referenced from a static context
BluetoothConnectionExample example = new BluetoothConnectionExample();
^
D:\Windev Mobile\GreenEcoPass\Android\Generation\src\com\secutech\greenecopass\wdgen\GWDCPCOL_Zebra.java:37: error: cannot find symbol
example.sendCpclOverBluetooth(theBtMacAddress);
^
symbol: method sendCpclOverBluetooth(String)
location: variable example of type GWDCPCOL_Zebra.BluetoothConnectionExample
D:\Windev Mobile\GreenEcoPass\Android\Generation\src\com\secutech\greenecopass\wdgen\GWDCPCOL_Zebra.java:32: error: Illegal static declaration in inner class GWDCPCOL_Zebra.BluetoothConnectionExample
public static void main(String[] args) {
^
modifier 'static' is only allowed in constant variable declarations
D:\Windev Mobile\GreenEcoPass\Android\Generation\src\com\secutech\greenecopass\wdgen\GWDFFEN_Login.java:974: error: cannot find symbol
GWDCPCOL_Zebra.BluetoothConnectionExample("74:F0:7D:E2:06:17");
^
symbol: method BluetoothConnectionExample(String)
location: class GWDCPCOL_Zebra
4 errors
FAILED


Le code JAVA est le suivant :

import android.os.Looper;

import com.zebra.sdk.comm.BluetoothConnection;
import com.zebra.sdk.comm.Connection;

public class BluetoothConnectionExample {

public static void main(String[] args) {
BluetoothConnectionExample example = new BluetoothConnectionExample();

String theBtMacAddress = "00:11:BB:DD:55:FF";
example.sendZplOverBluetooth(theBtMacAddress);
example.sendCpclOverBluetooth(theBtMacAddress);
}

private void sendZplOverBluetooth(final String theBtMacAddress) {

new Thread(new Runnable() {
public void run() {
try {
// Instantiate connection for given Bluetooth&reg; MAC Address.
Connection thePrinterConn = new BluetoothConnection(theBtMacAddress);

// Initialize
Looper.prepare();

// Open the connection - physical connection is established here.
thePrinterConn.open();

// This example prints "This is a ZPL test." near the top of the label.
String zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

// Send the data to printer as a byte array.
thePrinterConn.write(zplData.getBytes());

// Make sure the data got to the printer before closing the connection
Thread.sleep(500);

// Close the connection to release resources.
thePrinterConn.close();

Looper.myLooper().quit();
} catch (Exception e) {
// Handle communications error here.
e.printStackTrace();
}
}
}).start();
}
}


Quelqu'un aurait-il déjà mis en place ce genre de connexion ? Sinon est-ce faisable avec des fonctions WLanguage ?

Merci
Posté le 25 février 2016 - 23:46
Bjr,

Nico a pensé très fort :
Bonsoir,
Quelqu'un aurait-il déjà mis en place ce genre de connexion ? Sinon est-ce
faisable avec des fonctions WLanguage ?

Merci


En utilisant les sorties serie, ca marche pas ?
le BT peut etre géré comme un port serie,

a voir

a plus

--
-------------------------------------------------------------
www.ctc-soft.com
Gestion biblo-documentaire (free-share)
Comptabilité shareware
Logiciels de Gestion de saisie terrain
Spécialisé Tournées de boulangers
-------------------------------------------------------------
Posté le 26 février 2016 - 14:33
Les fonctions port série n'ont pas l'air dispo pour Android.
Posté le 27 février 2016 - 09:19
re,

Nico a présenté l'énoncé suivant :
> Les fonctions port série n'ont pas l'air dispo pour Android.

Ah merde tu as raison, excuse..

--
-------------------------------------------------------------
www.ctc-soft.com
Gestion biblo-documentaire (free-share)
Comptabilité shareware
Logiciels de Gestion de saisie terrain
Spécialisé Tournées de boulangers
-------------------------------------------------------------
Membre enregistré
4 messages
Posté le 01 mars 2019 - 15:29
Bonjour,
Auriez-vous la gentillesse d'afficher le code qui vous a permis de répondre à cette problématique, j'essaie moi-même d'imprimer sur des imprimantes BIXOLON, je pourrais adapter votre code dans mon appli.
Merci d'avance.
Posté le 16 mars 2020 - 11:07
Salut,
Avez-vous réussi à imprimer sur Bixolon? J'ai une imprimante sur laquelle je dois imprimer à partir d'une application Android.
Merci!
Posté le 16 mars 2020 - 11:08
Salut,
Avez-vous réussi à imprimer sur Bixolon? J'ai une imprimante sur laquelle je dois imprimer à partir d'une application Android.
Merci!