"Exception for the locationjava.lang.IndexOutOfBoundsException: Invalid index 0, size is 0"
I had this error for no reason in my android app which was able to fetch the current longitude latitude of current location using LocationTracker and later on by the help of Geocoder was able to display the name of the place in string.
I didnt see anything wrong with my code also before my app was working fine.
Later, I found out the problem was due to not granting permission for the app I had to go to
>>setting>>application>>app manager>>appname>>>>permissions and turn on the location toggle button.
After rerunning the app the problem was solved. My runtime message showed error in this line before solving the problem
String address = addresses.get(0).getAddressLine(0);
which is written under button listener for the button which on clicking we get the location of the place
Are there any other reasons possible for similar error?? Also I think good practice will be to place the code in MainActivity so one can grant the permission through the application itself and dont have to go to the setting>>application....and so on. Any suggestion in this matter?? also let me know whether the technique i used to solve the problem was right or not??