Good afternoon, I’m trying to start a GPS, but how can I not understand why in the created Fragment it red underlines all this as well as getSystemService?
public class GPS extends Fragment { private LocationManager locationManager; DBHelper dbHelper; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); dbHelper = new DBHelper(this); } @Override public void onResume() { super.onResume(); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000 * 10, 5, locationListener); locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 1000*10, 5, locationListener); } @Override public void onPause() { removeUpdates super.onPause(); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } locationManager.removeUpdates(locationListener); }