gpt4 book ai didi

android - PendingIntent 上的 "requestCode"用于什么?

转载 作者:IT老高 更新时间:2023-10-28 13:06:10 27 4
gpt4 key购买 nike

背景:

我正在通过 AlarmManager 使用 PendingIntent 进行警报。

问题:

一开始我以为要取消之前的,我必须提供我之前用来启动警报的确切 requestCode。

但后来我发现我错了,因为 cancellation API说:

Remove any alarms with a matching Intent. Any alarm, of any type, whose Intent matches this one (as defined by filterEquals(Intent)), will be canceled.

查看“filterEquals”,文档说:

Determine if two intents are the same for the purposes of intent resolution (filtering). That is, if their action, data, type, class, and categories are the same. This does not compare any extra data included in the intents.

所以我不明白“requestCode”的用途......

问题:

“requestCode”是做什么用的?

如果我使用相同的“requestCode”创建多个警报怎么办?它们会相互覆盖吗?

最佳答案

  1. requestCode 用于稍后检索相同的待处理 Intent 实例(用于取消等)。
  2. 是的,我的猜测是警报会相互覆盖。我会保持请求代码的唯一性。

关于android - PendingIntent 上的 "requestCode"用于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21526319/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com