geofencing - How to work with Geo Fence in android? -


i trying implement geo fence in android application . followed tutorial http://developer.android.com/training/location/geofencing.html. ,

enter code here

   mapfragment = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map));     googlemap = mapfragment.getmap();     // set onmarkerdrag listener     googlemap.setonmarkerdraglistener(this);     // radius distance geofencing boundary     distance = 1;     // move camera @ specific location.     // current location latitude , longitude can provided here     googlemap.movecamera(cameraupdatefactory.newlatlngzoom(new latlng(mylatitude, mylongitude), 1));      // creategeofence location latitude , longitude , shape     creategeofence(latitudegeofence, longitudegeofence, distance, "circle", "myoffice"); } private void creategeofence(double latitude, double longitude, int radius, string geofencetype, string title){     marker marker = googlemap.addmarker(new markeroptions().draggable(true).position(new latlng(latitude, longitude)).title(title).draggable(true).icon(bitmapdescriptorfactory.fromresource(r.drawable.lock)));    //marker.setanchor(10,10);      googlemap.addcircle(new circleoptions().center(new latlng(latitude, longitude)).radius(radius).strokecolor(color.parsecolor("#ffff00")).fillcolor(color.parsecolor("#b2a9f6"))); }  public void onmarkerdrag(marker marker){}  public void onmarkerdragend(marker marker){     latlng dragposition = marker.getposition();     double draglat = dragposition.latitude;     double draglong = dragposition.longitude;      googlemap.clear();     creategeofence(draglat, draglong, distance, "circle", "geofence"); } public void onmarkerdragstart(marker marker){} @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.menu_fencing, menu);     return true; } 

but not working, did not notification of entring , exititng in android app. please me how develop geo-fencing , how notifications in application . thabks in advance.

public class simplegeofence {      private final string mid;     private final double mlatitude;     private final double mlongitude;     private final float mradius;     private long mexpirationduration;     private int mtransitiontype;      public simplegeofence(string geofenceid, double latitude, double longitude, float radius,long expiration, int transition) {          this.mid = geofenceid;         this.mlatitude = latitude;         this.mlongitude = longitude;         this.mradius = radius;         this.mexpirationduration = expiration;         this.mtransitiontype = transition;     }      public string getid() {         return mid;     }     public double getlatitude() {         return mlatitude;     }     public double getlongitude() {         return mlongitude;     }     public float getradius() {         return mradius;     }     public long getexpirationduration() {         return mexpirationduration;     }     public int gettransitiontype() {         return mtransitiontype;     }       public geofence togeofence() {         return new geofence.builder()             .setrequestid(mid)             .settransitiontypes(mtransitiontype)             .setcircularregion(mlatitude, mlongitude, mradius)             .setexpirationduration(mexpirationduration)             .build();     } } 

private geofencingrequest getgeofencingrequest() {     geofencingrequest.builder builder = new geofencingrequest.builder();     builder.setinitialtrigger(geofencingrequest.initial_trigger_enter);     builder.addgeofences(mgeofencelist);return builder.build(); } 

try one, may helpful you.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -