|
@@ -266,10 +266,16 @@ public class SystemUtil {
|
266
|
266
|
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
267
|
267
|
String bestProvider = "";
|
268
|
268
|
List<String> providers = locationManager.getProviders(true);
|
269
|
|
- if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
|
270
|
|
- ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
271
|
|
- &&ActivityCompat.checkSelfPermission(context,Manifest.permission.ACCESS_BACKGROUND_LOCATION)== PackageManager.PERMISSION_GRANTED
|
272
|
|
- ) {
|
|
269
|
+ boolean flag=false;
|
|
270
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
|
|
271
|
+ flag=( ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
|
|
272
|
+ ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
|
|
273
|
+ &&ActivityCompat.checkSelfPermission(context,Manifest.permission.ACCESS_BACKGROUND_LOCATION)== PackageManager.PERMISSION_GRANTED);
|
|
274
|
+ }else {
|
|
275
|
+ flag=( ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
|
|
276
|
+ ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED);
|
|
277
|
+ }
|
|
278
|
+ if (flag) {
|
273
|
279
|
for (String provider : providers) {
|
274
|
280
|
Location lastKnownLocation =locationManager.getLastKnownLocation(provider);
|
275
|
281
|
if (lastKnownLocation==null){
|