【问题标题】:Why does android RemoteView class provide only setOnClickPendingIntent为什么android RemoteView类只提供setOnClickPendingIntent
【发布时间】:2023-04-09 20:26:01
【问题描述】:

Android 的RemoteView 类提供了setOnClickPendingIntent 方法,而不是setOnClickListener。这是什么原因?在这种情况下使用PendingIntent 有什么好处?

【问题讨论】:

  • iirc 远程视图未在您的应用程序进程中运行,因此它必须使用 IPC 告诉您的应用程序单击了某些内容。这是异步的,因此它是“待定”点击,而不是即时点击。该名称反映了细微的行为差异。
  • @Blundell 将您的评论变成答案。

标签: android android-pendingintent remoteview android-remoteview


【解决方案1】:

iirc

远程视图未在您的应用程序进程中运行,因此它必须使用IPC 告诉您的应用程序点击了某些内容。这是异步的,因此它是“待定”点击,而不是即时点击。该名称反映了细微的行为差异。

#setOnClickPendingIntent(int, android.app.PendingIntent)

#setOnClickListener(android.view.View.OnClickListener)

【讨论】:

  • Intent 和 PendingIntent 之间肯定存在一些行为差异,否则setOnClickIntent(int, Intent) 足以满足微妙的命名,不是吗?
  • 是的,但问题不在于Intent vs PendingIntent 更多关于onClick 来自RemoteView vs onClick 来自View
猜你喜欢
  • 1970-01-01
  • 2019-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-06
  • 2011-02-23
  • 2010-10-05
  • 2018-09-01
相关资源
最近更新 更多