How to use "setCloseAction"?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start in MainActivity at updatePictureInPictureParams and follow the shown createRemoteAction and broadcastReceiver paths. Reproduce the Picture-in-Picture close action, then verify that selecting it triggers the close control and finishes the Activity.
Written by the indexing model from the issue text.
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 -> [email protected]()
}
}
}
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
}
- Dominant language
- Kotlin
- Stars
- 1.4k
- Forks
- 777
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from android/media-samples
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
android/media-samples#117 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
android/media-samples#116 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 15/100
android/media-samples#112 ·
-
بانلبرلبتOpen
Difficulty 5/5 Over a week Newbie friendliness 1/100
android/media-samples#111 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
android/media-samples#92 · 3 comments ·
All issues in android/media-samples
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
MetrolistGroup/Metrolist#5426 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
🐛 Type:Bug 📥 State:Awaiting Assignment 🚨 Priority: P0 - Critical
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
micronizationlab/glafira-ai-hub#785 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sorsama/deepseek-harness-mobile#154 ·
Maintainers usually reply within 1 day
-
0. Needs triage enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day