Код: Выделить всё
Starting FGS with type location callerApp=ProcessRecord{22f416f 27792:smartsense.co.in.sensephone:remote/u0a255} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permissionЯ добавил проверку разрешений перед запуском службы переднего плана.
Код: Выделить всё
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
if (Utils.checkLocationPermission(this)) {
ServiceCompat.startForeground(this, AUTO_ATTENDANCE_ID, getNotification(getString(R.string.please_enable_gps), activityPendingIntent), FOREGROUND_SERVICE_TYPE_LOCATION);
} else {
Utils.appendLog(TAG, "Location permissions denied for ASIOFS to start", this);
}
} else {
startForeground(AUTO_ATTENDANCE_ID, getNotification(getString(R.string.please_enable_gps), activityPendingIntent));
}
Код: Выделить всё
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
return PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
&& PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
} else {
return PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);
}
Я прочитал все возможные документы, но единственное, что у меня есть, это то, что я использую ActivityCompat.checkSelfPermission( ) и в документации предлагается использовать PermissionChecker.checkSelfPermission().
Если у вас есть возможное решение, дайте мне знать.
Подробнее здесь: https://stackoverflow.com/questions/791 ... andorid-14
Мобильная версия