Geo Fencing

22 views
Skip to first unread message

Bhakav

unread,
Nov 19, 2016, 11:24:27 PM11/19/16
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans
Desktop OS  Ubuntu
Simulator  Codeone Simulator
Device     Galaxy Samsung 7
Using free service right now ( doing evaluation )

I am trying to implement geofencing which is the key part of development and don't have success so far , few questions and issues I am having and pls correct me if I am wrong 

1) There is no support to test Geofence on simulator .I have to make the change make the build install on my device and test  and when I do not see expected result I have no idea why it is failing and have to repeat the process 


 I added a button with below action listener 

{
               
        Location loc = new Location();
        
        loc.setLatitude(30.167043);
        loc.setLongitude(-74.0059413);
        
        Geofence gf = new Geofence("test", loc, 1999, 100000);
        LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
        
                
        });


I made sure by using fake gps itenary  that I  travel through this location on my device . When I click on the button Android ask permission to access the device location

public class GeofenceListenerImpl implements GeofenceListener {
    @Override
    public void onExit(String id) {
         LocalNotification ln = new LocalNotification();
            ln.setId("LnMessage1");
            ln.setAlertTitle("Bye ");
            ln.setAlertBody("Bye!");
             Display.getInstance().scheduleLocalNotification(ln,  System.currentTimeMillis() + 80 * 1000, LocalNotification.REPEAT_NONE);
    }

    @Override
    public void onEntered(String id) {
        System.out.println("com.mycompany.myapp.GeofenceListenerImpl.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!");
            Display.getInstance().scheduleLocalNotification(ln,  System.currentTimeMillis() + 80 * 1000, LocalNotification.REPEAT_NONE);
        }
    }    
}


But the issue is I never see any notifications . Any help will be appreciated .

3) Do I need to minimize or close the app for geofence  to work ( I have tried both and both don't work) 
4) Is there any way to get the list of geofence being created ?
5) Any way to simulate the behavior on local simulator 

Shai Almog

unread,
Nov 20, 2016, 12:38:22 AM11/20/16
to CodenameOne Discussions
Reply all
Reply to author
Forward
0 new messages