Hi! im tryng to implement the geofence in my code but it didnt work. is a 
problem in the class or i'm no doing something?  im testing on android.


my code is attached 

thanks! Roman

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/6473483c-1e37-4397-a4a6-73c411081f2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.romanola.CeliGUIDE;

import com.codename1.io.Log;
import com.codename1.location.Geofence;
import com.codename1.location.Location;
import com.codename1.location.LocationManager;
import com.codename1.maps.BoundingBox;
import com.codename1.maps.Coord;
import static com.romanola.CeliGUIDE.MyApplication.URL_DIRECTORY_SERVICIOS;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Maneja el sistema de geofence
 *
 * @author roman
 */
public class GeoFence {
    
    public GeoFence() {
        Timer t = new Timer();
        TimerTask ta = new TimerTask() {
            
            public void run() {
                // code that has to be executed after 3 secs.
                LocationManager.getLocationManager().getCurrentLocationSync();
                loadLocales();
            }
        };
        
        t.schedule(ta, 100, 60 * 1000);
        
    }
    
    protected void loadLocales() {
        
        Location loc = new Location();
        loc.setLatitude(-34.585940);
        loc.setLongitude(-58.504650);
        loc.setVelocity(0);
        String locId = "00001";
        int segundo = 1000;
        Geofence gf = new Geofence(locId, loc, 10000, 60 * segundo);
        LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
        
    }
}
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.romanola.CeliGUIDE;

import com.codename1.location.GeofenceListener;
import com.codename1.notifications.LocalNotification;
import com.codename1.ui.Dialog;
import com.codename1.ui.Display;

/**
 *
 * @author roman
 */
public class GeofenceListenerImpl implements GeofenceListener {

    @Override
    public void onExit(String id) {
    }
    
    @Override
    public void onEntered(String id) {
        
     //   Alert.show("onEntered");
        if (Display.getInstance().isMinimized()) {
            Display.getInstance().callSerially(() -> {
                Dialog.show("Welcome", "Thanks for arriving", "OK", null);
            });
        } else {
            LocalNotification ln = new LocalNotification();
            ln.setId("LnMessage");
            ln.setAlertTitle("Welcome");
            ln.setAlertBody("Thanks for arriving!");
            try {
                Display.getInstance().scheduleLocalNotification(ln, 10, LocalNotification.REPEAT_NONE);
            } catch (Exception ex) {
                Alert.show(ex.getMessage());
            }
            
        }
    }    
}

Reply via email to