Wait for gps location

i have a problem with the gps.
when i start the app there will be a time for find the gps and i have made this:

but the app crash.
there is another method?

Looks like your list takes a long time to be not empty, which means that the while loop will stop user from interacting with the ui thread as long as your condition became false, which causes your app to crash. I think a better way is to use a clock, to wait until the google maps component gets the location, i think that won’t crash my app , according to my tests.