Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
The logical place for that would be in the model, which contains the business logic, and database access components.
Sometimes a consequence of having a layered architecture, is the need for 'pass through' methods. But without seeing your code, I can't really say anything very specific. Can you provide some sample code to illustrate the problems you're having?
private void checkPermissions() {
Log.i(TAG, "ACCESS_FINE_LOCATION check");
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "ACCESS_FINE_LOCATION request");
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
showRequestPermission(REQUEST_CODE_LOCATION);
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_CODE_LOCATION);
}
} else {
Log.i(TAG, "ACCESS_FINE_LOCATION granted");
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case REQUEST_CODE_LOCATION: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "ACCESS_FINE_LOCATION granted");
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.i(TAG, "GPS provider enabled");
} else {
Log.i(TAG, "GPS provider disabled");
}
Log.i(TAG, "Listening to location updates...");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
}
} else {
Log.i(TAG, "ACCESS_FINE_LOCATION denied");
}
return;
}
}
}
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "Listening to location updates...");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DISTANCE, locationListener);
}
try {
Log.i(TAG, "Listening to location updates...");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DISTANCE, locationListener);
} catch (SecurityException se) {
se.printStackTrace();
}
When you say you moved the LocationManager to the 'model', what do you mean by that? What constitutes the 'model' in your application?
Just found a nice article on app architecture here
https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#0