I have tried a lot of different solutions to get the current location (latitude and longitude) in a fragment, but I cant figeraut how to get it. Every Time I have tried I get the latitude and longitude 0, so there is any util class to get it or someone how can tell me how can I do it?
Below you can see some details about what I have tried.
dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.mcxiaoke.volley:library:1.0.16'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
}
Permission:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
I have tried this solution: https://stackoverflow.com/a/3145655/2545964 but nothing.
Also I have tried this code: https://github.com/googlesamples/android-play-location/blob/master/BasicLocationSample/app/src/main/java/com/google/android/gms/location/sample/basiclocationsample/MainActivity.java and I dont get any error but the latitude and longitude still null..
someone who can help me? Thanks!!