-
Notifications
You must be signed in to change notification settings - Fork 779
Open
Description
I tried to use "PictureInPictureParams.Builder.setCloseAction(RemoteAction)" to finish Activity, but is not work. what should i do?
private const val ACTION_STOPWATCH_CONTROL = "stopwatch_control"
private const val EXTRA_CONTROL_TYPE = "control_type"
private const val CONTROL_TYPE_CLOSE = 3
private const val REQUEST_CLOSE = 5
private val broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent == null || intent.action != ACTION_STOPWATCH_CONTROL) {
return
}
when (intent.getIntExtra(EXTRA_CONTROL_TYPE, 0)) {
CONTROL_TYPE_CLOSE -> this@MainActivity.finish()
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
...
registerReceiver(broadcastReceiver, IntentFilter(ACTION_STOPWATCH_CONTROL))
}
private fun updatePictureInPictureParams(started: Boolean): PictureInPictureParams {
val params = PictureInPictureParams.Builder()
.setAspectRatio(Rational(16, 9))
.setSeamlessResizeEnabled(false)
.setAutoEnterEnabled(true)
.setCloseAction(
createRemoteAction(
R.drawable.close,
R.string.close,
REQUEST_CLOSE,
CONTROL_TYPE_CLOSE
)
)
.build()
setPictureInPictureParams(params)
return params
}
txfyxzzytxfyxzzy
Metadata
Metadata
Assignees
Labels
No labels