We were forced to remove it due to google App Store policy.
override fun onKeyEvent(event: KeyEvent?): Boolean {
return when (event?.keyCode) {
KEYCODE_GUIDE -> {
Log.v("RemoteButton", "${event}")
if (event.action == ACTION_DOWN) {
launchMainActivity(extras = mapOf("tab" to "guide"))
}
true
}
KEYCODE_DVR -> {
Log.v("RemoteButton", "${event}")
if (event.action == ACTION_DOWN) {
launchMainActivity(extras = mapOf("tab" to "dvr_library"))
}
true
}
KEYCODE_TV,
5124 /* LIVE on TiVo remote */ -> {
Log.v("RemoteButton", "${event}")
if (event.action == ACTION_DOWN) {
launchPlayerLive()
}
true
}
fun launchMainActivity(flags: Int = 0, extras: Map<String, String>? = null) {
val intent = instance.packageManager.getLeanbackLaunchIntentForPackage(instance.packageName)
intent?.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or flags)
extras?.forEach {
intent?.putExtra(it.key, it.value)
}
instance.startActivity(intent)
}
}
fun launchPlayerLive(channel: String? = null) {
val intent = Intent(
Intent.ACTION_VIEW,
"channels://${BuildConfig.APPLICATION_ID}/play/channel/$channel".toUri(),
instance,
MainActivity::class.java
)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
instance.startActivity(intent)
}