FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV Mobile (précédentes versions)
→
Imprimer sur android avec java code
Imprimer sur android avec java code
Débuté par nac, 13 nov. 2015 17:03 - Aucune réponse
Connectez-vous…
nac
#1
Membre enregistré
29 messages
Posté le 13 novembre 2015 - 17:03
Bonjour à tous,
WM n'ayant pas de fonction d'impression sous android , je voudrais intégrer un code java qui le fait.
J'ai trouvé ceci mais lors du déploiement je reçois plusieurs erreurs :
Quelqu'un peut-il m'aider ?
Merci d'avance
Nac
Voici le code java que j'ai placé dans une procédure globale :
========================================
import java.io.*;
import java.util.*;
import javax.comm.*;
public static void main(String args) {
Enumeration portList;
CommPortIdentifier portId;
String messageString = "Hello, world!\n";
SerialPort serialPort;
OutputStream outputStream;
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM1")) {
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
} catch (PortInUseException e) {}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
try {
outputStream.write(messageString.getBytes());
} catch (IOException e) {}
serialPort.close();
}
}
}
}
//
Et voici le message d'erreur :
===================
Echec de la création de l'application Android <C:\sysd\WELLPRO\VodaPos\Exe\VodaPos.apk>.
Ligne de commande : "C:\Program Files\Java\jdk1.8.0_51\bin\javac.exe" -encoding UTF-16LE -nowarn -source 1.5 -target 1.5 -d bin\classes -bootclasspath "C:\Program Files\Android\android-sdk\platforms\android-22\android.jar" gen\com\masociete\vodapos\*.java src\com\masociete\vodapos\wdgen\*.java -classpath "libs;libs\android-support-v4.jar"
Erreur retournée :
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:17: error: package javax.comm does not exist
import javax.comm.*;
^
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:30: error: cannot find symbol
CommPortIdentifier portId;
^
symbol: class CommPortIdentifier
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:32: error: cannot find symbol
SerialPort serialPort;
^
symbol: class SerialPort
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:35: error: cannot find symbol
portList = CommPortIdentifier.getPortIdentifiers();
^
symbol: variable CommPortIdentifier
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:37: error: cannot find symbol
portId = (CommPortIdentifier) portList.nextElement();
^
symbol: class CommPortIdentifier
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:38: error: cannot find symbol
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
^
symbol: variable CommPortIdentifier
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:41: error: cannot find symbol
serialPort = (SerialPort)
^
symbol: class SerialPort
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:43: error: cannot find symbol
} catch (PortInUseException e) {}
^
symbol: class PortInUseException
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:49: error: cannot find symbol
SerialPort.DATABITS_8,
^
symbol: variable SerialPort
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:50: error: cannot find symbol
SerialPort.STOPBITS_1,
^
symbol: variable SerialPort
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:51: error: cannot find symbol
SerialPort.PARITY_NONE);
^
symbol: variable SerialPort
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDCPProceduresGlobales.java:52: error: cannot find symbol
} catch (UnsupportedCommOperationException e) {}
^
symbol: class UnsupportedCommOperationException
location: class GWDCPProceduresGlobales
src\com\masociete\vodapos\wdgen\GWDFFen_items.java:6011: error: method main in class GWDCPProceduresGlobales cannot be applied to given types;
GWDCPProceduresGlobales.main();
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
13 errors
Signaler
0
0
→ Revenir à WINDEV Mobile (précédentes versions)
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
WEBDEV (précédentes versions)
WINDEV Mobile (précédentes versions)
Etats & Requêtes
Hors-sujet
Outils
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte