Register and unregister locationmanager

This commit is contained in:
misaochan 2016-08-22 18:07:30 +12:00
parent 7dd48e092c
commit 043c970999

View file

@ -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();
}
}