【问题标题】:Estimote: Send a Notification to User when iBeacon is nearEstimote:当 iBeacon 靠近时向用户发送通知
【发布时间】:2014-06-17 18:13:13
【问题描述】:

我正在修改 Estimote 提供的 Demo App。目前,当我进入信标区域时,我会收到通知,然后除非我退出该区域,否则我不会再收到任何通知。 我希望每次更改最近的信标时都收到通知。也就是说,如果最近的信标是绿色的,那么我想收到一个通知,但是如果 2 秒后最近的信标是蓝色的,我想收到另一个通知。 然后我会以某种方式过滤通知..

我有一个名为 NotifyApp 的类,它扩展了一个应用程序。我不知道我是否必须使用不同的 MonitoringListener 方法,一个用于每个区域,或者我应该使用 RangingListener..

 public void onCreate() {
   super.onCreate();
   notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
   beaconManager = new BeaconManager(this);

   beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(1), 0);

   for (int i=0; i<3; i++) {
     region = new Region("rid", null, null, MyBeacons.getInstance().getMinor(i));

     beaconManager.setMonitoringListener(new MonitoringListener() { 
       @Override
       public void onEnteredRegion(Region region, List<Beacon> beacons) {
         postNotification("MONITORING: Beacon " + MyBeacons.getInstance().getColor(beacons.get(0).getMinor()));
       }
       @Override
       public void onExitedRegion(Region region) {
         postNotification("Exited region");
       }
     });
  } 
}

【问题讨论】:

    标签: android notifications ibeacon estimote


    【解决方案1】:

    Monitoring API 仅用于发现进入和退出区域。

    从您的用例看来,您想使用测距 API。您应该在发现带有监控的信标后立即使用它。

    【讨论】:

    • 嘿,wikor,在发现带有监控的信标后,我们如何开始使用 rangeListener?我们是否在 setMonitoringListener 的 onEnteredRegion 函数中调用 setRangingListener?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-22
    • 1970-01-01
    相关资源
    最近更新 更多