【问题标题】:GeofencingEvent.fromIntent(Intent) returns nullGeofencingEvent.fromIntent(Intent) 返回 null
【发布时间】:2022-10-24 04:47:38
【问题描述】:

我按照this 教程使用 Java。正如预期的那样,BroadcastReceiver 接收到一个 Intent,但 GeofencingEvent fromIntent (Intent intent) 方法返回 NULL。 根据fromIntent 的文档:

返回 - 一个 GeofencingEvent 对象,如果给定的 Intent 为 null,则返回 null 或不包含地理围栏事件

可能的原因是什么?

【问题讨论】:

    标签: android android-intent android-geofence


    【解决方案1】:

    当我写这个问题时,我注意到了错误: 在较新的版本中,PendingIntent.getBroadcast 强制您选择PendingIntent.FLAG_MUTABLEPendingIntent.FLAG_UNMUTABLE。我选择了 FLAG_UNMUTABLE... 显然,如果 Intent 不可变,则 Intent 无法填充 GeofenceEvent 信息......

    【讨论】:

      猜你喜欢
      • 2014-11-16
      • 1970-01-01
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 2013-01-11
      • 2023-01-30
      • 1970-01-01
      相关资源
      最近更新 更多