android - Get Current Location GMaps -


i tried lot of "get current location" android. think of them outdated, or dont it.

i dont want set marker.addmarker(params..) use blue default dot position on gmaps. here i've found somthing that, bad aint work.

customize marker of mylocation google maps v2 android

so in first line need, current location listener when location updating. im trying right (testing on real device). mylocation =null.

    //get gmaps fragment     mmap = ((mapfragment)getfragmentmanager().findfragmentbyid(r.id.map)).getmap();     mmap.setmylocationenabled(true);    //activate blue dot      mylocation = mmap.getmylocation();  //testing, not working = null      //trying locationmanager     locmanager =(locationmanager)getsystemservice(this.location_service);     criteria criteria = new criteria();     string provider = locmanager.getbestprovider(criteria, true);      mylocation = locmanager.getlastknownlocation(provider);     if(mylocation != null){         double lat = mylocation.getlatitude();         double lon = mylocation.getlongitude();     }      locmanager.requestlocationupdates(provider, 1000, 0, new locationlistener() {         @override         public void onlocationchanged(location location) {             mylocation = location;         }          @override         public void onstatuschanged(string provider, int status, bundle extras) {          }          @override         public void onproviderenabled(string provider) {          }          @override         public void onproviderdisabled(string provider) {          }     }); 

follow http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/ . place latitude , longitude get(using gps.getlatitude(), gps.getlongitude()) in google map , show current location.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -