IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windev Mobile Discussion :

Code java dans une fonction windev mobile


Sujet :

Windev Mobile

  1. #1
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2014
    Messages
    93
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2014
    Messages : 93
    Points : 166
    Points
    166
    Par défaut Code java dans une fonction windev mobile
    Bonjour,
    Après avoir galéré (pour rester poli...) pour compiler avec Windev Mobile une fonction java important trois classes externes à Android, j'essaye maintenant d'écrire, avec pour seul support l'unique exemple fourni avec matériel (Téléphone avec imprimante intégrée) une fonction globale de type java juste pour imprimer du texte...

    Pour tester j’essaie un truc simple : récupérer le numéro de série de l'imprimante....

    Code java : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    public static void PrintData(String sData)
    {
    	IWoyouService woyouService;
     
    	Toast.makeText(getApplicationContext(), "Etape 3 : ".concat(sData), Toast.LENGTH_SHORT).show();
    	Intent intent = new Intent();
    	intent.setPackage("woyou.aidlservice.jiuiv5");
    	intent.setAction("woyou.aidlservice.jiuiv5.IWoyouService");
    	woyouService.getPrinterSerialNo();
    };

    La compil sort l'erreur :
    error: variable woyouService might not have been initialized
    woyouService.getPrinterSerialNo();
    ^
    error: unreported exception RemoteException; must be caught or declared to be thrown
    woyouService.getPrinterSerialNo();
    ^
    Comment initialiser woyouService ?
    Si je met IWoyouService woyouService = new IWoyouService();
    j'ai l'erreur :
    java:45: error: IWoyouService is abstract; cannot be instantiated

    Exemple fourni :
    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.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.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;
     
    	Toast.makeText(getApplicationContext(), "Etape 3 : ".concat(sData), Toast.LENGTH_SHORT).show();
     
    	Intent intent = new Intent();
    	intent.setPackage("woyou.aidlservice.jiuiv5");
    	intent.setAction("woyou.aidlservice.jiuiv5.IWoyouService");
    	startService(intent);
    }

    La compilation génère l'erreur suivante :

    src\com\masociete\bus\wdgen\GWDCPProceduresGlobales.java:52: error: cannot find symbol
    startService(intent);
    ^
    symbol: method startService(Intent)
    location: class GWDCPProceduresGlobales
    1 error

    Code de l'exemple :
    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
    121
    122
     
    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("Essais via Eclipse");
    		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("Message de test 001.");
     
    			}
    		});
    	}
     
    	private void printTexte(String str){
    		try {
    			woyouService.printText(str+"\n",callback);
    		} catch (RemoteException e) {
    			e.printStackTrace();
    		}catch (Exception e) {
    			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 {
    			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);
     
    		}		
    	};
     
    	@Override
    	protected void onPause() {
    		super.onStop();
     
    	}
    }

  2. #2
    Futur Membre du Club
    Femme Profil pro
    Développeur informatique
    Inscrit en
    Février 2015
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 44
    Localisation : France, Aveyron (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2015
    Messages : 4
    Points : 5
    Points
    5
    Par défaut Avez-vous jamais réussi à faire fonctionner un import java dans windev mobile ?
    J'écume tous les forums à la recherche d'un seul exemple probant de projet windev mobile utilisant du code java natif...
    Sans succès, la doc de pcsoft reste soigneusement évasive à ce sujet et se garde bien de clarifier les choses.
    Est-ce votre cas ?

Discussions similaires

  1. Invocation méthode objet JAVA dans une fonction JAVASCRIPT
    Par makao dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 11/10/2010, 23h04
  2. JSP : mettre du code java dans une fonction javascript
    Par padraig29 dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 11/08/2010, 10h07
  3. code java dans une facelet
    Par Jacobian dans le forum JSF
    Réponses: 2
    Dernier message: 03/11/2008, 13h23
  4. code java dans une jsp
    Par mima_mine dans le forum Struts 1
    Réponses: 16
    Dernier message: 27/08/2008, 16h01
  5. [Java] cast de classe Java dans une fonction Matlab
    Par steph_ch dans le forum MATLAB
    Réponses: 1
    Dernier message: 14/04/2008, 15h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo