You can actually request a single update, which is probably what you want in this situation.
kris On Wed, Aug 8, 2012 at 10:50 AM, bob <[email protected]> wrote: > I would say move a lot of your code to your LocationListener in this > function: > > onLocationChanged(Location location) > Called when the location has changed. > > > > On Wednesday, August 8, 2012 7:13:26 AM UTC-5, Ece Osmanağaoğlu wrote: >> >> I wanna get current location. >> There is null pointer exception in List<Address> >> >> locMan = (LocationManager) >> this.getSystemService(Context.LOCATION_SERVICE); >> gpsProv = LocationManager.GPS_PROVIDER; >> locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, >> 250, Kampusler.this); >> myGeo = new Geocoder(Kampusler.this, Locale.getDefault()); >> >> loc = locMan.getLastKnownLocation(gpsProv); >> try >> { >> List<Address> adres = myGeo.getFromLocation(loc.getLatitude(), >> loc.getLongitude(), 1); >> if(adres != null) >> { >> for(int i=0; i < >> adres.get(0).getMaxAddressLineIndex(); i++) >> { >> result += adres.get(0).getAddressLine(i) + "\n"; >> } >> } >> else >> { >> Toast.makeText(Kampusler.this, "Don't get address...", >> Toast.LENGTH_LONG).show(); >> } >> } >> catch (Exception e) >> { >> e.printStackTrace(); >> Toast.makeText(getApplicationContext(), e.getMessage(), >> Toast.LENGTH_SHORT).show(); >> } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

