mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-04 08:43:52 +01:00
Add permission check for location
This commit is contained in:
parent
043c970999
commit
1530ddc969
2 changed files with 25 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ public class NearbyActivity extends AppCompatActivity {
|
|||
private double currentLatitude, currentLongitude;
|
||||
private String gpsCoords;
|
||||
|
||||
private static final String TAG = "NearbyActivty";
|
||||
private static final String TAG = "NearbyActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
@ -48,7 +48,7 @@ public class NearbyActivity extends AppCompatActivity {
|
|||
* Registers a LocationManager to listen for current location
|
||||
*/
|
||||
protected void registerLocationManager() {
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
|
||||
criteria = new Criteria();
|
||||
provider = locationManager.getBestProvider(criteria, true);
|
||||
myLocationListener = new MyLocationListener();
|
||||
|
|
@ -83,6 +83,7 @@ public class NearbyActivity extends AppCompatActivity {
|
|||
public void onLocationChanged(Location location) {
|
||||
currentLatitude = location.getLatitude();
|
||||
currentLongitude = location.getLongitude();
|
||||
Log.d(TAG, "Latitude: " + String.valueOf(currentLatitude) + " Longitude: " + String.valueOf(currentLongitude));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue