I`ve got following class:
package com.google.sl.util;

import android.Manifest;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.google.android.gms.location.ActivityRecognition;
import com.google.android.gms.location.ActivityTransition;
import com.google.android.gms.location.ActivityTransitionRequest;
import com.google.android.gms.location.DetectedActivity;
import com.google.sl.data.SensorRecorder;
import com.google.sl.data.TransitionReceiver;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ForegroundService extends Service {

    private SensorRecorder sensorRecorder;
    private PendingIntent transitionPendingIntent;

    private boolean isActivityRecognitionActive = false;
    private boolean isSensorRecordingActive = false;

    // Define actions
    public static final String ACTION_START_ACTIVITY_RECOGNITION = "ACTION_START_ACTIVITY_RECOGNITION";
    public static final String ACTION_STOP_ACTIVITY_RECOGNITION = "ACTION_STOP_ACTIVITY_RECOGNITION";
    public static final String ACTION_START_SENSOR_RECORDING = "ACTION_START_SENSOR_RECORDING";
    public static final String ACTION_STOP_SENSOR_RECORDING = "ACTION_STOP_SENSOR_RECORDING";
    public static final String ACTION_STOP_SERVICE = "ACTION_STOP_SERVICE";

    private NotificationHelper notificationHelper;

    @Override
    public void onCreate() {
        super.onCreate();
        notificationHelper = new NotificationHelper(this);

        // Start the service in the foreground with a notification
        Notification notification = notificationHelper.createNotification("Service Running", "Tap to open app");
        startForeground(NotificationHelper.NOTIFICATION_ID, notification);

        // Initialize SensorRecorder
        sensorRecorder = new SensorRecorder(this, event -> {
            // Handle sensor data
            Log.d("ForegroundService", "Sensor: " + event.sensor.getName() + ", Values: " + Arrays.toString(event.values));
        });
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (intent != null) {
            String action = intent.getAction();

            if (ACTION_START_ACTIVITY_RECOGNITION.equals(action)) {
                startActivityRecognition();
            } else if (ACTION_STOP_ACTIVITY_RECOGNITION.equals(action)) {
                stopActivityRecognition();
            } else if (ACTION_START_SENSOR_RECORDING.equals(action)) {
                startSensorRecording();
            } else if (ACTION_STOP_SENSOR_RECORDING.equals(action)) {
                stopSensorRecording();
            } else if (ACTION_STOP_SERVICE.equals(action)) {
                stopSelf();
            }
        }

        return START_STICKY;
    }

    private void startActivityRecognition() {
        if (isActivityRecognitionActive) {
            return;
        }

        // Check for permissions
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACTIVITY_RECOGNITION) != PackageManager.PERMISSION_GRANTED) {
            // Handle permission not granted
            Log.e("ForegroundService", "Activity recognition permission not granted");
            stopSelf();
            return;
        }

        // Build transitions you're interested in
        List<ActivityTransition> transitions = new ArrayList<>();
        // Define the activity types you're interested in
        int[] activityTypes = {
                DetectedActivity.WALKING,
                DetectedActivity.RUNNING,
                DetectedActivity.IN_VEHICLE,
                DetectedActivity.ON_BICYCLE,
                DetectedActivity.STILL
        };

        // Add enter and exit transitions for each activity type
        for (int activityType : activityTypes) {
            transitions.add(new ActivityTransition.Builder()
                    .setActivityType(activityType)
                    .setActivityTransition(ActivityTransition.ACTIVITY_TRANSITION_ENTER)
                    .build());
            transitions.add(new ActivityTransition.Builder()
                    .setActivityType(activityType)
                    .setActivityTransition(ActivityTransition.ACTIVITY_TRANSITION_EXIT)
                    .build());
        }

        ActivityTransitionRequest request = new ActivityTransitionRequest(transitions);

        // Create a pending intent to handle the transitions
        Intent transitionIntent = new Intent(this, TransitionReceiver.class);
        transitionPendingIntent = PendingIntent.getBroadcast(this, 0, transitionIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);

        // Register for activity transitions
        ActivityRecognition.getClient(this)
                .requestActivityTransitionUpdates(request, transitionPendingIntent)
                .addOnSuccessListener(aVoid -> {
                    Log.i("ForegroundService", "Successfully started activity recognition");
                    isActivityRecognitionActive = true;
                }).addOnFailureListener(e -> {
                    Log.e("ForegroundService", "Failed to start activity recognition", e);
                    stopSelf();
                });
    }

    private void stopActivityRecognition() {
        if (isActivityRecognitionActive && transitionPendingIntent != null) {
            ActivityRecognition.getClient(this)
                    .removeActivityTransitionUpdates(transitionPendingIntent)
                    .addOnSuccessListener(aVoid -> {
                        Log.i("ForegroundService", "Successfully stopped activity recognition");
                        isActivityRecognitionActive = false;
                    }).addOnFailureListener(e -> {
                        Log.e("ForegroundService", "Failed to stop activity recognition", e);
                    });
        }
    }

    private void startSensorRecording() {
        if (isSensorRecordingActive) {
            return;
        }
        sensorRecorder.startRecording();
        isSensorRecordingActive = true;
        Log.i("ForegroundService", "Sensor recording started");
    }

    private void stopSensorRecording() {
        if (isSensorRecordingActive) {
            sensorRecorder.stopRecording();
            isSensorRecordingActive = false;
            Log.i("ForegroundService", "Sensor recording stopped");
        }
    }

    @Override
    public void onDestroy() {
        stopActivityRecognition();
        stopSensorRecording();
        super.onDestroy();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}

but I dont need permission check here, because I`ve already got another class:
package com.google.sl.util;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;

import androidx.annotation.NonNull;

import java.util.List;

import pub.devrel.easypermissions.EasyPermissions;

public class PermissionManager implements EasyPermissions.PermissionCallbacks {

    private static final int PERMISSION_REQUEST_CODE = 123;
    @SuppressLint("StaticFieldLeak")
    private static PermissionManager instance;
    private final Context context;

    private PermissionListener permissionListener;

    public interface PermissionListener {
        void onPermissionsGranted();

        void onPermissionsDenied(List<String> deniedPermissions);
    }

    private PermissionManager(Context context) {
        this.context = context;
    }

    public static PermissionManager getInstance(Context context) {
        if (instance != null) {
            return instance;
        }
        synchronized (PermissionManager.class) {
            if (instance == null) {
                instance = new PermissionManager(context.getApplicationContext());
            }
        }
        return instance;
    }

    public void setPermissionListener(PermissionListener listener) {
        this.permissionListener = listener;
    }

    public void checkAndRequestPermissions(Activity activity) {
        String[] perms = {Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACTIVITY_RECOGNITION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.FOREGROUND_SERVICE, Manifest.permission.FOREGROUND_SERVICE_DATA_SYNC,
                // Add other permissions
        };

        if (EasyPermissions.hasPermissions(context, perms)) {
            // All permissions have been granted
            if (permissionListener != null) {
                permissionListener.onPermissionsGranted();
            }
        } else {
            // Request permissions
            EasyPermissions.requestPermissions(activity, "This app needs access to your physical activity to function properly.", PERMISSION_REQUEST_CODE, perms);
        }
    }

    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
        if (requestCode == PERMISSION_REQUEST_CODE) {
            // Check if all required permissions have been granted
            if (EasyPermissions.hasPermissions(context, perms.toArray(new String[0]))) {
                if (permissionListener != null) {
                    permissionListener.onPermissionsGranted();
                }
            }
        }
    }

    @Override
    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
        if (requestCode == PERMISSION_REQUEST_CODE) {
            if (permissionListener != null) {
                permissionListener.onPermissionsDenied(perms);
            }
        }
    }

    // Forwarding the result to EasyPermissions
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }
}