
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
25 lines
746 B
Kotlin
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))
|
|
}
|
|
}
|
|
}
|
|
}
|