mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Register and unregister locationmanager
This commit is contained in:
parent
7dd48e092c
commit
043c970999
1 changed files with 22 additions and 1 deletions
|
|
@ -20,6 +20,9 @@ public class NearbyActivity extends AppCompatActivity {
|
|||
private String provider;
|
||||
private Criteria criteria;
|
||||
|
||||
private double currentLatitude, currentLongitude;
|
||||
private String gpsCoords;
|
||||
|
||||
private static final String TAG = "NearbyActivty";
|
||||
|
||||
@Override
|
||||
|
|
@ -27,9 +30,20 @@ public class NearbyActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_nearby);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
registerLocationManager();
|
||||
}
|
||||
|
||||
//TODO: Get user's location
|
||||
@Override
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
|
||||
registerLocationManager();
|
||||
//TODO: Check if we need String or double coords, and in what format
|
||||
gpsCoords = String.valueOf(currentLatitude) + "|" + String.valueOf(currentLongitude);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a LocationManager to listen for current location
|
||||
*/
|
||||
|
|
@ -86,4 +100,11 @@ public class NearbyActivity extends AppCompatActivity {
|
|||
Log.d(TAG, "Provider " + provider + " disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy(){
|
||||
super.onDestroy();
|
||||
|
||||
unregisterLocationManager();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue