I'm developing an android application which is supposed to get the location of the android device when the activity is created (onCreate)
. But it returns 0 longitude and 0 latitude when activity is created. When I click the button, the location is then fetched.
How can I get the location when the activity starts, instead of getting the location after clicking on the button?
-All permissions are granted
-I'm calling the same functions in onCreate()
and onClick()
to get the location.
-I'm using googleAPI to get the location of the device