It takes time for a location to be available. But it looks like you are just looking for the last known location which can be null.
How are you waiting for location updates? On Aug 8, 2012 8:13 AM, "Ece Osmanağaoğlu" <[email protected]> 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

