Bonjour,
L'interface GPS de WINDEV MOBILE ne permettant pas d'accéder aux informations "fines" du GPS, je désire créer une procédure Java pour avoir ces infos.
Dans Android, cela passe par la création de deux listeners (donc asynchrones)
- un pour le location update
- l'autre pour le statut du GPS
Dans une procédure Java native, j'ai donc créé deux méthodes ayant pour but de répondre à ce type d'événement (location update et changement du status du GPS).
Le souci que je rencontre maintenant, c'est comment puis-je transférer les informations vues par ces listeners vers mon programme Windev Mobile ? J'ai essayé de passer par une écriture dans un champ de la fenêtre (avec un getView préalable), mais visiblement cela plante .....
Voici mon code
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 ///// import android.location.GpsSatellite; import android.location.GpsStatus; import android.location.Location; import android.location.LocationListener; import android.location.GpsStatus.*; import android.location.LocationManager; import android.content.*; import java.util.Iterator; import android.util.Log; import android.widget.TextView; public static void Location_listener() { /////////////////////////////////////////// // écriture TextView myTextView; myTextView = (TextView) getView ("LIB_log"); myTextView.setText("avant init listener"); //////////////////////////////////// // Récupération du contexte et du location manager Context myContext = getContexteApplication(); LocationManager mylocationManager = (LocationManager) myContext.getSystemService(Context.LOCATION_SERVICE); ////////////////////////////////////////// // Define a listener that responds to location updates LocationListener mylocationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. TextView myTextView; myTextView = (TextView) getView ("LIB_log"); myTextView.setText("onLocationChanged"); } public void onStatusChanged(String provider, int status, Bundle extras) { TextView myTextView; myTextView = (TextView) getView ("LIB_log"); myTextView.setText("onStatusChanged"); } public void onProviderEnabled(String provider) { TextView myTextView; myTextView = (TextView) getView ("LIB_log"); myTextView.setText("onProviderEnabled"); } public void onProviderDisabled(String provider) { TextView myTextView; myTextView = (TextView) getView ("LIB_log"); myTextView.setText("onProviderDisabled"); } }; ////////////////////////////////////// /////////////////////////////////////// // Define a listener that responds to GPS STATUS GpsStatus.Listener mygpsStatusListener = new GpsStatus.Listener() { public void onGpsStatusChanged(int event){ // plantage si on essaye d'afficher le texte // TextView myTextView; // myTextView = (TextView) getView ("LIB_log"); // myTextView.setText("event !!!!!!! "); } }; /////////////////////////////////////// // Register the listener with the Location Manager to receive location updates mylocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mylocationListener); mylocationManager.addGpsStatusListener(mygpsStatusListener); myTextView.setText("apres init listener"); }
Partager