Chạy hai foreground service cùng lúc

Chào mọi người hiện em đang muốn chạy hai foreground service cùng lúc,service đầu em chạy dùng startForegroundService,code đây ạ:

private fun actionOnService(action: Actions) {
    if (getServiceState(this) == ServiceState.STOPPED && action == Actions.STOP) return
    Intent(this, EndlessService::class.java).also {
        it.action = action.name
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            log("Starting the service in >=26 Mode")
            startForegroundService(it)

Liệu để chạy thêm một service nữa thì em phải làm sao ạ. Cảm ơn mọi người giúp đỡ. Em hỏi thêm trên stack

Dùng 3 dấu ``` code here ```` để post code nha

# Code o day
        if (getServiceState(this) == ServiceState.STOPPED && action == Actions.STOP) return Intent(this, EndlessService::class.java).also {
                    it.action = action.name
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                        log("Starting the service in >=26 Mode") startForegroundService(it)
2 Likes

@@ cảm ơn anh em dùng co 1 dấu `

1 Like

Post lại code đi nhòm cho phê bạn.

3 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?