PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV Mobile 2024 → Importation de class Java dans le projet Mobile
Importation de class Java dans le projet Mobile
Started by Gemini1961, Jul., 30 2020 2:10 PM - 7 replies
Posted on July, 30 2020 - 2:10 PM
Bonjour à toutes et tous

Après avoir parcouru l'aide en ligne, je n'ai pas trouvé la façon d'intégrer des class écrites en Java dans un projet WD Mobile 24

Une personne connait-elle la marche à suivre ?

Merci pour votre aide ;-)

Bien cordialement
Registered member
22 messages
Posted on July, 30 2020 - 4:26 PM
Bonjour, on ne peut intégrer directement des classes. Il faut d'abord la transformer en .jar ou .aar.

Il est possible également de créer une fonction en java, il suffit de créer un procédure windev, puis dans le cade de la procédure, cliquer sur le cadre "WL" qui se trouve tout en haut à coté du texte "Procédure globale nomDeLaProcedure" et choisir java.
Registered member
286 messages
Popularité : +24 (28 votes)
Posted on July, 30 2020 - 6:13 PM
Bonsoir Clément

Merci pour ta réponse :-)

J'ai effectivement créer des librairies .jar et j'ai essayé de les joindre aux projets via listes des éléments du projet

mais impossible d'appeler la moindre méthode de ces librairies via une procédure ( en code java donc pas de WL ... ) cela génère une erreur :-(

J'avoue que je suis un peu perdu, cela me semblait pourtant si simple ....

Bonne soirée ;-)
Registered member
22 messages
Posted on July, 31 2020 - 10:41 AM
Pour t'aider, il me faudrait l'erreur et le code de ta procédure.
Registered member
12 messages
Popularité : +7 (7 votes)
Posted on July, 24 2021 - 4:46 PM
//https://www.youtube.com/watch?v=BXwDM5VVuKA&ab_channel=ProgrammingExperts
//https://developer.android.com/guide/components/services
//<manifest ... >
//...
//<application ... >
//<service android:name=".ExampleService" />
//...
//</application>
//</manifest>

import android.app.Service;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.content.Context;
import android.app.Activity;
import android.os.ResultReceiver;

import android.view.View;
import android.widget.Toast;

PUBLIC class myService extends Service {

int startMode; // indicates how to behave if the service is killed
IBinder binder; // interface for clients that bind
boolean allowRebind; // indicates whether onRebind should be used

//@Override
// public IBinder onBind(Intent intent) {
// // We don't provide binding, so return null
// Toast.makeText(this, "IBinder onBind(Intent intent)", Toast.LENGTH_SHORT).show();
// return null;
// }

@Override
PUBLIC void onCreate() {
// The service is being created
Toast.makeText(this, "onCreate()", Toast.LENGTH_SHORT).show();
appelProcedureWL("WLAndroid_AfficheInfo", "onCreate()");
}
@Override
PUBLIC int onStartCommand(Intent intent, int flags, int startId) {
// The service is starting, due to a call to startService()
Toast.makeText(this, "onStartCommand : The service is starting, due to a call to startService()", Toast.LENGTH_SHORT).show();
RETURN startMode;
}
@Override
PUBLIC IBinder onBind(Intent intent) {
// A client is binding to the service with bindService()
Toast.makeText(this, "IBinder onBind : A client is binding to the service with bindService()", Toast.LENGTH_SHORT).show();
RETURN binder;
}
@Override
PUBLIC boolean onUnbind(Intent intent) {
// All clients have unbound with unbindService()
Toast.makeText(this, "onUnbind : All clients have unbound with unbindService()", Toast.LENGTH_SHORT).show();
RETURN allowRebind;
}
@Override
PUBLIC void onRebind(Intent intent) {
// A client is binding to the service with bindService(),
// after onUnbind() has already been called
Toast.makeText(this, "after onUnbind() has already been called", Toast.LENGTH_SHORT).show();
}

@Override
PUBLIC void onDestroy() {
Toast.makeText(this, "onDestroy() : service done", Toast.LENGTH_SHORT).show();
}


}//END Class myClass



// Variables
PUBLIC static string TAG = "WM SMS";
PUBLIC static string msCallback = "";

PUBLIC static void StartServiceWithJava()
{
//Toast.makeText(getActiviteEnCours(), "StartServiceWithJava()", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getActiviteEnCours(), myService.class);

//Intent intent = new Intent(getContexteApplication(), ActiviteCreeEnJava.class);
//getActiviteEnCours().startActivity(intent);

// Le code Java est susceptible de générer des exceptions en cas de problème
// On l'entoure par une structure try/catch
try {
getActiviteEnCours().startService(intent);
Toast.makeText(getActiviteEnCours(), "startService()", Toast.LENGTH_SHORT).show();

//si la version est ORIO ou superier
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
// getActiviteEnCours().startForegroundService(intent);
// Toast.makeText(getActiviteEnCours(), "startForegroundService()", Toast.LENGTH_SHORT).show();
// }else{
// getActiviteEnCours().startService(intent);
// Toast.makeText(getActiviteEnCours(), "startService()", Toast.LENGTH_SHORT).show();
// }

// Si une exception se produit, elle est récupérée et affichée
}catch ( EXCEPTION e ) {
appelProcedureWL("WLAndroid_AfficheInfo", e.getMessage());
}
finally {

}



}//FIN StartServiceWithJava


--
ChMoeZ
Posted on October, 28 2022 - 2:08 PM
Bonjour,

Avez-vous réussi à trouver une solution pour surcharger des méthodes Java ?

Je suis actuellement confronté au même souci dans windev mobile 27.

Merci
Posted on December, 19 2022 - 11:21 PM
Je peux vous aider pour lintegration
Posted on December, 29 2022 - 1:59 PM
J'aurais besoin de votre aide pour ajouter des class et les appeler via une procédure.