Bonjour,
Configuration hardware :
Mobile : CITAQ V1-G https://citaq.en.alibaba.com/product...h_Printer.html
Au niveau logiciel je n'ai que ce fichier V1 API.rar qui contient du java avec un seul exemple (voir ci-dessous). l'idée est de créer dans Windev Mobile une procédure globale de type java : PrintData(<données à imprimer>) qui comme son nom l'indique enverra à l'imprimante intégrée au mobile le texte à imprimer.
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 import woyou.aidlservice.jiuiv5.ICallback; import woyou.aidlservice.jiuiv5.IWoyouService; import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public static void PrintData(String sData) { //Toast.makeText(getApplicationContext(), sData, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.setPackage("woyou.aidlservice.jiuiv5"); intent.setAction("woyou.aidlservice.jiuiv5.IWoyouService"); //startService(intent); //bindService(intent, connService, Context.BIND_AUTO_CREATE); //printTexte("maman va au marché"); }
Je rajoute, le fichier D:\Mes Projets Mobile V20\Bus\V1 API\V5Print\libs\android-support-v4.jar et la compilation me sort l'erreur suivante :
Où faut-il donc mettre les fichiers ICallback.class, IWoyouService.class et IYmodemSPI.class (ainsi que les xxx.aidl, xxx$Stub.class et xxx$Stub$Proxy.class) ???Echec de la création de l'application Android <D:\Mes Projets Mobile V20\Bus\Exe\Bus.apk>.
Ligne de commande : "C:\Program Files (x86)\Java\jdk1.8.0_112\bin\javac.exe" -encoding UTF-8 -nowarn -source 1.5 -target 1.5 -d bin\classes -bootclasspath "C:\Program Files (x86)\Android\android-sdk\platforms\android-25\android.jar" gen\com\masociete\bus\*.java src\com\masociete\bus\wdgen\*.java -classpath "libs;bin\classes;libs\android-support-v4.jar"
Erreur retournée :
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:32: error: package woyou.aidlservice.jiuiv5 does not exist
import woyou.aidlservice.jiuiv5.IWoyouService;
^
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:33: error: package woyou.aidlservice.jiuiv5 does not exist
import woyou.aidlservice.jiuiv5.ICallback;
^
2 errors
Peut être faut-il copier le répertoire V5Print... mais où ?
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 package com.citaq.v5print; import woyou.aidlservice.jiuiv5.ICallback; import woyou.aidlservice.jiuiv5.IWoyouService; import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity { Button bt_print; Button bt_print_portugal; EditText et_text; protected static final String TAG = null; IWoyouService woyouService; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = new Intent(); intent.setPackage("woyou.aidlservice.jiuiv5"); intent.setAction("woyou.aidlservice.jiuiv5.IWoyouService"); startService(intent); bindService(intent, connService, Context.BIND_AUTO_CREATE); printTexte("maman va au marché"); init(); } private void init(){ bt_print = (Button) findViewById(R.id.bt_print); bt_print_portugal = (Button) findViewById(R.id.bt_print_portugal); et_text = (EditText) findViewById(R.id.et_text); bt_print.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { printTexte(et_text.getText().toString()); } }); bt_print_portugal.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { printTexte("A nação Chinesa desde OS tempos antigos,é um defensor Da paz."); } }); } private void printTexte(String str){ try { woyouService.printText(str+"\n",callback); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private ServiceConnection connService = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { woyouService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { woyouService = IWoyouService.Stub.asInterface(service); try { woyouService.printerInit(callback) ; // 注册回调函数 } catch (RemoteException e) { Log.d(TAG, "registerCallback failed."); } } }; private ICallback callback = new ICallback.Stub() { @Override public void onRunResult(boolean isSuccess) throws RemoteException { // TODO Auto-generated method stub Log.d(TAG, "ICallback--->" + isSuccess); } @Override public void onReturnString(String result) throws RemoteException { // TODO Auto-generated method stub Log.d(TAG, "ICallback--->" + result); } @Override public void onRaiseException(int code, String msg) throws RemoteException { Log.d(TAG, "onRaiseException--->" + msg); } }; @Override protected void onPause() { // TODO Auto-generated method stub super.onStop(); } }
Merci d'avance...
C'est de pire en pire...
Je viens d'installer
Eclipse for Android Developers
Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200
J'ouvre le projet V5Print et la c'est le contraire il résout bien les imports "woyou.aidlservice.jiuiv5..." mais pas les imports "android..."
Idem si je lui demande de créer un nouveau projet !
Existe-t-il un document sur le net qui donne de bonnes infos car cela fait 3 jours que je tourne en rond !!!
Enfin en bidouillant j'ai réussi à supprimer le message d'erreur sur les "import android..."
Maintenant qu'il n'y a plus d'erreur je tente une exportation du projet "Clic droit" sur V5Print "Export" puis "Android Application"
Message : "There is no android project named V5Print", par contre "Close project" fonctionne... C'est vraiment "désespérant" (pour rester poli) ce système...
Partager