Files
mpd/android/app/src/main/java/org/musicpd/AutomationReceiver.kt
Colin Edwards fff9ceccc2 android: Add intents for service start and stop
org.musicpd.action.StartService
org.musicpd.action.StopService

You can test these actions like:
adb shell am broadcast -a org.musicpd.action.StartService org.musicpd

Calling these from an app like tasker should allow for automation
2024-04-05 23:46:14 -05:00

25 lines
746 B
Kotlin

package org.musicpd
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
class AutomationReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when(intent.action) {
"org.musicpd.action.StartService" -> {
val wakelock = Preferences.getBoolean(
context,
Preferences.KEY_WAKELOCK, false
)
Main.startService(context, wakelock)
}
"org.musicpd.action.StopService" -> {
context.startService(Intent(context, Main::class.java)
.setAction(Main.SHUTDOWN_ACTION))
}
}
}
}