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

Reply via email to