Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Mise à jour notification lorsque les coordonnées GPS changent

Featured Replies

Posté(e)

Bonjour,

Pour mon projet scolaire je dois récupérérer des coordonnées GPS en permanence, donc j'ai créé un service de ce coté tout fonctionne.

Le problème c'est que ma barre de notification ne se met pas à jour lors ce que les coordonnées GPS changent, pour mettre à jour mes coordonnées j'utilise un Listener.
 

 

code :

public class MajListener implements LocationListener {
 
    @[member=override]
    public void onLocationChanged(Location location) {
 
        Service_GPS.miseAjourCoordonnees(location);
 
        Service_GPS.val = true;
 
    }

et pour la méthode de la notification qui est présente dans le service Service_GPS mais impossible à déclarer en static à cause du getSystemService..

 

code :

public void showNotification()
    {
        // Build notification
        // Actions are just fake
        Notification noti = new Notification.Builder(this)
                .setContentTitle("Positions GPS ")
                .setContentText(latitude +" "+longitude).setSmallIcon(R.drawable.ic_launcher).build();
 
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 
        notificationManager.notify(0, noti);
        lo=longitude;
        la=latitude;
    }

et puis le code de l'appelle du LocationListener :

// Récupération d'une instance du LocationManager
        String locationContext = Context.LOCATION_SERVICE;
        monLocationManager=(LocationManager)getSystemService(locationContext);
 
 
        if(monLocationManager !=null && monLocationProvider!=null)
        {
            //Vérification toutes les 10 secondes (10000 millisecondes ) si la position change
            //d'au moins 10 mètres. Si c'est le cas, l'écouteur (instance de MajListener)
            //va etre averti
 
            monLocationManager.requestLocationUpdates(monLocationProvider,1000,1,new MajListener());
        }

Merci

Rejoignez la conversation

Vous pouvez poster maintenant et vous enregistrez plus tard. Si vous avez un compte, connectez-vous maintenant pour poster.

Invité
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Répondre à ce sujet…

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.