Bonjour,
Complétement néophyte en java et pris par le temps, je recherche de l'aide sur java pour Andoid.
Mon soucis est le suivant :
J'ai un smartphone avec imprimante intégrée de la marque CITAQ et question logiciel + doc cela se résume juste en un petit fichier contenant un exemple avec le .jar, .class... le minimum vital.
Le développement se fait avec Windev Mobile qui peut intégrer des procédures en java.
Mon but c'est d'avoir juste une petite fonction fonction java. Je suis complétement bloqué a cette étape !
Voici mon code
et la compilation me sort :
Code : 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 import woyou.aidlservice.jiuiv5.IWoyouService; import woyou.aidlservice.jiuiv5.ICallback; import android.app.Activity; import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; 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) { IWoyouService woyouService; final String TAG = null; Toast.makeText(getApplicationContext(), "Etape 1 : ".concat(sData), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.setPackage("woyou.aidlservice.jiuiv5"); intent.setAction("woyou.aidlservice.jiuiv5.IWoyouService"); getApplicationContext().startService(intent); //getApplicationContext().bindService(intent, connService, Context.BIND_AUTO_CREATE); //---------------------------------------------------------------------------------- ICallback callback = new ICallback.Stub() { @Override public void onRunResult(boolean isSuccess) throws RemoteException { Log.d(TAG, "ICallback--->" + isSuccess); } @Override public void onReturnString(String result) throws RemoteException { Log.d(TAG, "ICallback--->" + result); } @Override public void onRaiseException(int code, String msg) throws RemoteException { Log.d(TAG, "onRaiseException--->" + msg); } }; //---------------------------------------------------------------------------------- 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."); } } }; };
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:85: error: variable woyouService might not have been initialized
woyouService.printerInit(callback);
^
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:79: error: local variable woyouService is accessed from within inner class; needs to be declared final
woyouService = null;
^
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:83: error: local variable woyouService is accessed from within inner class; needs to be declared final
woyouService = IWoyouService.Stub.asInterface(service);
^
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:85: error: local variable callback is accessed from within inner class; needs to be declared final
woyouService.printerInit(callback);
^
Vu que le compilateur me dit : local variable woyouService is accessed from within inner class; needs to be declared final, je met
"final" devant "IWoyouService woyouService;" et la compilation me sort :
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:79: error: cannot assign a value to final variable woyouService
woyouService = null;
^
src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:83: error: cannot assign a value to final variable woyouService
woyouService = IWoyouService.Stub.asInterface(service);
^
2 errors
et la je bloque complétement !!!
Partager