Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 11 Monaten, 1 Woche
Letzter Beitrag:
vor 11 Monaten, 1 Woche
Beteiligte Autoren:
Peter Muckle, Arie

Wm20: how to use java classes

Startbeitrag von Peter Muckle am 09.02.2017 20:45

Hi All,

I have a folder with some java class files I need to integrate with an app. I have no java experience and have never done this before.

Can someone give me a few pointers about where to start! Where do the files go, how are they accessed etc.

Thanks very much

Pete

Antworten:

Hi Pete,

below is a simple example of a Java function. You can create one by creating a new global procedure. This will be a WL procedure by default, and you can switch that to Java by ticking the WL in the upper left of the prcedure title bar.
All the import you need for the function to work prpoerly also go into this section.

You can call this function directly from your normal WL code by calling JavaInternetConnected().

Most of the java functions use libraries already integrated in Android on the devide. No need to add them again. If you want to use external libraries you have to include them in the APK file.In the creation wizard for generating the Android APK there is a page for that called "including libraries". Afaik these files go into your applications install map and the app will find them automatically when run.



import android.content.Context;
import android.net.ConnectivityManager;

public static boolean JavaInternetConnected() {
Context c = getApplicationContext();
ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isAvailable()
&& cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
//Log.v(TAG, "Internet Connection Not Present");
return false;
}
}



von Arie - am 10.02.2017 18:34
Thanks Arie

von Peter Muckle - am 12.02.2017 16:11
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.