So I've tried to get the users location and wanted it to popup as a Toast() or in the Logs but nothing happens.
I've added <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> to the manifest and this is my class:
public class MainActivity extends AppCompatActivity {
private LocationManager locationManager;
private LocationListener locationListener;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get the users location
locationManager = (LocationManager)
this.getSystemService(Context.LOCATION_SERVICE);
locationListener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
Log.i("LOCATION", location.toString());
Toast.makeText(MainActivity.this, location.toString(),
Toast.LENGTH_SHORT).show();
}
#Override
public void onStatusChanged(String provider, int status, Bundle
extras) {
Log.i("STATUS", String.valueOf(status));
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
};
// Ask users permission to get location
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},1);
} else {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
}
}
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
}
}
}
}
}
The app asks for permission the first time and after I accept it doesn't show any signs of getting a location from the OnStatusChanges() method. I've tried to get lastKnownLocation()and it works but that's all...
Any idea what's missing?
Thanks!
Related
I'm working with the map to my app and so I have here a weird error message that it says java.lang.SecurityException: "GPS" location provider requires ACCESS_FINE_LOCATION permission. every time I launch the app and crashes due to this error, though I already have a permission checker.
Here is my code:
public class FragmentHome extends Fragment implements OnMapReadyCallback {
/*
Set up's
*/
private static final String TAG = "FragmentHome";
/*
Pallete
*/
private MapView mapView;
private GoogleMap gMap;
private static final String MAP_VIEW_BUNDLE_KEY = "SOME_KEY";
#SuppressLint("SetJavaScriptEnabled")
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view_fragmentInflate = inflater.inflate(R.layout.fragment_fragment_home, container, false);
mapView = (MapView) view_fragmentInflate.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
return view_fragmentInflate;
}
#Override
public void onMapReady(GoogleMap googleMap) {
getUserLocation();
}
private void getUserLocation() {
LocationManager locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
Log.i(TAG, "onLocationChanged: " + location);
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
getContext().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// Activity#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 Activity#requestPermissions for more details.
requestPermissions(new String[] {
Manifest.permission.ACCESS_FINE_LOCATION
}, 1);
}
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
3000, 0, locationListener);
}
}
I really do not know where I went wrong from this line of code, to keep my app crashing and give me that error.
Update your code with bellow code may solve your problem
public class FragmentHome extends Fragment implements OnMapReadyCallback {
/*
Set up's
*/
private static final String TAG = "FragmentHome";
/*
Pallete
*/
private MapView mapView;
private GoogleMap gMap;
private static final String MAP_VIEW_BUNDLE_KEY = "AIzaSyDWL-JNHiCXvQefgFh1BdaAflJTveSrHJo";
#SuppressLint("SetJavaScriptEnabled")
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view_fragmentInflate = inflater.inflate(R.layout.fragment_fragment_home, container, false);
mapView = (MapView) view_fragmentInflate.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
return view_fragmentInflate;
}
boolean isMapReady;
#Override
public void onMapReady(GoogleMap googleMap) {
isMapReady=true;
getUserLocation();
}
private void getUserLocation() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(getContext(),Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(getContext(),Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// Activity#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 Activity#requestPermissions for more details.
requestPermissions(new String[]{
Manifest.permission.ACCESS_FINE_LOCATION
}, 1);
return;
}
}
LocationManager locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
Log.i(TAG, "onLocationChanged: " + location);
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
};
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
3000, 0, locationListener);
}
}
Now override onRequestPermissionsResult() and check if result is granted and isMapReady flag true then call getUserLocation().
So the solution for this and base on the comments i forgot to put the else statement that if the permission is granted then execute the listener else request a permission.
Updated:
public class FragmentHome extends Fragment implements OnMapReadyCallback {
/*
Set up's
*/
private static final String TAG = "FragmentHome";
/*
Pallete
*/
private MapView mapView;
private GoogleMap gMap;
private static final String MAP_VIEW_BUNDLE_KEY = "AIzaSyDWL-JNHiCXvQefgFh1BdaAflJTveSrHJo";
#SuppressLint("SetJavaScriptEnabled")
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view_fragmentInflate = inflater.inflate(R.layout.fragment_fragment_home, container, false);
mapView = (MapView) view_fragmentInflate.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
return view_fragmentInflate;
}
#Override
public void onMapReady(GoogleMap googleMap) {
checkGPSPermission();
getUserLocation();
}
private void checkGPSPermission() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if(getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if(shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) {
// show why is important
}
requestPermissions(new String[] {
Manifest.permission.ACCESS_FINE_LOCATION
}, 1);
} else {
// granted
}
} else {
// granted
}
}
private void getUserLocation() {
LocationManager locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
Log.i(TAG, "onLocationChanged: " + location);
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
getContext().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// Activity#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 Activity#requestPermissions for more details.
requestPermissions(new String[] {
Manifest.permission.ACCESS_FINE_LOCATION
}, 1);
} else {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
3000, 0, locationListener);
}
} else {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
3000, 0, locationListener);
}
}
}
I want to use locationListener in my android fragment. But I am getting an error. My code is in below.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LocationListener locationListener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
}
};
locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 1, locationListener);
}
else {
}
}
I am getting this error.
Can't resolve method requestLocationUpdates
Implement all the methods of LocationListener
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
TextView textView = new TextView(getActivity());
textView.setText(R.string.hello_blank_fragment);
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
if (new Utility().checkAndGrantPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION, 101, "your custom message"))
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 1, locationListener);
}
return textView;
}
Outside from onCreate
LocationListener locationListener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
//Todo your code
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
//Todo your code
}
#Override
public void onProviderEnabled(String provider) {
//Todo your code
}
#Override
public void onProviderDisabled(String provider) {
//Todo your code
}
};
And the checkAndGrantPermission method is
public boolean checkAndGrantPermission(final Context context, final String permissionString, final int requestCode, String permissoinTypeMessage)
{
int currentAPIVersion = Build.VERSION.SDK_INT;
if(currentAPIVersion>=android.os.Build.VERSION_CODES.M)
{
if (ContextCompat.checkSelfPermission(context, permissionString) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, permissionString)) {
// your custom dialog screen when user deny permission
} else {
ActivityCompat.requestPermissions((Activity) context, new String[]{permissionString}, requestCode);
}
return false;
} else {
return true;
}
} else {
return true;
}
}
In Activity override onRequestPermissionsResult
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 101) {
yourFragmentInstance.onRequestPermissionsResult(requestCode,permissions,grantResults);
}
}
In Your Framgent override onRequestPermissionsResult
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 101) {
if (requestCode == AppConstants.runtimePermissionCode) {
if (permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION) && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 1, locationListener);
}
}
}
}
Got your issue.
You have used Location listener from
com.google.android.gms.location.LocationListener;
You have to import LocationListener from
android.location.Location;
Try this one:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 1, new android.location.LocationListener() {
#Override
public void onLocationChanged(Location location) {
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
});
Hope it helps:)
Create this class:
public class GetCurrentLocation implements
ConnectionCallbacks, OnConnectionFailedListener, LocationListener {
private static final String TAG = "location-updates-sample";
public static final long UPDATE_INTERVAL_IN_MILLISECONDS = 0;
public static final long FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS =
UPDATE_INTERVAL_IN_MILLISECONDS / 2;
private final String REQUESTING_LOCATION_UPDATES_KEY = "requesting-location-updates-key";
private final String LOCATION_KEY = "location-key";
private final String LAST_UPDATED_TIME_STRING_KEY = "last-updated-time-string-key";
private GoogleApiClient mGoogleApiClient;
private LocationRequest mLocationRequest;
private Context mContext;
private getLocation mGetCurrentLocation;
public GetCurrentLocation(Context context) {
mContext = context;
buildGoogleApiClient();
}
private synchronized void buildGoogleApiClient() {
Log.i(TAG, "Building GoogleApiClient");
mGoogleApiClient = new GoogleApiClient.Builder(mContext)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
createLocationRequest();
}
public interface getLocation{
public void onLocationChanged(Location location);
}
public void startGettingLocation(getLocation location) {
mGetCurrentLocation = location;
connect();
}
public void stopGettingLocation() {
stopLocationUpdates();
disconnect();
}
private void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
private void startLocationUpdates() {
if (mGoogleApiClient.isConnected()) {
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
}
private void stopLocationUpdates() {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
private void connect() {
mGoogleApiClient.connect();
}
private void disconnect() {
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
}
#Override
public void onConnected(Bundle connectionHint) {
Log.i(TAG, "Connected to GoogleApiClient");
startLocationUpdates();
}
#Override
public void onLocationChanged(Location location) {
mGetCurrentLocation.onLocationChanged(location);
}
#Override
public void onConnectionSuspended(int cause) {
Log.i(TAG, "Connection suspended");
mGoogleApiClient.connect();
}
#Override
public void onConnectionFailed(ConnectionResult result) {
Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + result.getErrorCode());
}
}
In your fragment class:
private GetCurrentLocation mListen;
mListen = new GetCurrentLocation(this);
mListen.startGettingLocation(new GetCurrentLocation.getLocation() {
#Override
public void onLocationChanged(Location location) {
// Here is my working with location object
}
});
make sure you have added latest googleplayservice library in your gradle file.
Used this code on previous app and all seems ok - but today im getting a
call requires permission which may be rejected by user
I have added
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
to manifest and have read several threads on the subject, but still having issues. Could you guys helps out.
public class MainActivity extends AppCompatActivity implements LocationListener
{
private LocationManager locationManager;
public static String locationlong;
public static String locationlati;
#SuppressWarnings("deprecation")
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView)findViewById(R.id.pig);
TextView cow = (TextView)findViewById(R.id.cow);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 1, this);
}
}
Add the permission check in your activity:
in your code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.pig);
TextView cow = (TextView) findViewById(R.id.cow);
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 0);
}
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (checkLocationPermission()) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 1, this);
}
}
public boolean checkLocationPermission() {
String permission = "android.permission.ACCESS_FINE_LOCATION";
int res = this.checkCallingOrSelfPermission(permission);
return (res == PackageManager.PERMISSION_GRANTED);
}
#Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case 0: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getApplicationContext(), "Permission granted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Permission denied", Toast.LENGTH_SHORT).show();
}
return;
}
// other 'case' lines to check for other
// permissions this app might request
}
}
#Override
public void onLocationChanged(Location location) {
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
Basically since android 6 you need to ask certain permissions on runtime , so the user may reject them.
Use checkSelfPermission(..) to ask for it and override onRequestPermissionsResult to see the answer.
Here's a link with the full example:
https://developer.android.com/training/permissions/requesting.html
The error I get is as follows
Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Please tell me where I'm going wrong
Activity onCreate function
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mbutton=(Button)findViewById(R.id.partymb);
textview=(TextView)findViewById(R.id.tv);
setContentView(R.layout.activity_menuact);
locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationlistener = new LocationListener() {
#Override
public void onLocationChanged(Location location) {
textview.append("\n "+location.getLongitude() +" "+location.getLatitude());
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
Intent intent=new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
};
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{
Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.INTERNET
},10);
return;
}
} else {
configureButton();
}
}
onRequestPermissionResult function
public void onRequestPermissionResult(int requestCode, String[] permission, int[] grantResults) {
switch (requestCode){
case 10:
if(grantResults.length>0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
configureButton();
return;
}
}
ConfigureButton function
private void configureButton() {
mbutton.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
locationmanager.requestLocationUpdates("gps", 5000, 5, locationlistener);
}
});
}
I took reference from here
setContentView(R.layout.activity_menuact);
Above line should come immediately after super.onCreate(savedInstanceState);
And after that do findViewById.
You are finding views before setting a view so all views will be null only.
you are setting view and id before
setContentView(R.layout.activity_menuact);
you should set like below
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menuact);
mbutton=(Button)findViewById(R.id.partymb);
textview=(TextView)findViewById(R.id.tv);
}
I am using this code in android 6.0 to get the position:
public class MainActivity extends AppCompatActivity implements LocationListener{
protected LocationManager locationManager;
protected LocationListener locationListener;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (checkPermission())
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
#Override
public void onLocationChanged(Location location) {
lati = location.getLatitude();
longi = location.getLongitude();
}
#Override
public void onProviderDisabled(String provider) {
Log.d("Latitude", "disable");
}
#Override
public void onProviderEnabled(String provider) {
Log.d("Latitude", "enable");
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d("Latitude", "status");
}
private boolean checkPermission(){
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 false;
}
return true;
}
}
I set the permissions in the programs properties to true.
It used to work but now it never finds satellites or the position in general.
Google maps immediately finds satellites.
What do I need to change?
see all that TODO comment in your code? implement it. you must do this for it to work on modern versions of andorid