基于服务的多个接近警报 [英] multiple proximity alert based on a service

查看:169
本文介绍了基于服务的多个接近警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的应用程序,它使用ProximityAlerts当用户在指定的无线电设备进入火起来。

I have my application, which uses ProximityAlerts to fire up when the user enters on the designated radios.

我proximityAlert触发了它显示了一个面包,告诉我,我已经进入了活动的指定电台的服务。

My proximityAlert fires up a service which shows a Toast telling me that I've entered the designated radio of the events.

问题来了,我不能让我的应用程序解雇几个注册地点,它只是反应已注册的最后一个而忽略了早期注册的事件

The problem comes that I cannot make my application to fire several registered locations, it only react to the last one that was registered and ignore the earlier registered events

任何帮助吗?我已经看到了使用广播接收器的人,但我的情况下,我使用的是服务,而不是

Any help please? I have seen people using broadcast receiver but in my case I use a service instead.

推荐答案

要建立与接近警报的Andr​​oid应用程序,其主要成分是广播接收器,意图的PendingIntent和AddProximityAlert。

To build an Android app with proximity alert, the main ingredient are Broadcast Receiver, Intent, PendingIntent, and AddProximityAlert.

工作流程应该如下: -

The workflow should be as following: -


  1. 注册一个广播接收器
  2. 的的IntentFilter
  3. 创建一个Intent

  4. 获取将进行广播一的PendingIntent

  5. 设置接近警报

  1. Register an IntentFilter with a Broadcast Receiver
  2. Create an Intent
  3. Get a PendingIntent that will perform a broadcast
  4. Set proximity alert

为了让您的应用火的几个地点注册,您必须先注册与正确的IntentFilter广播接收器,并为每个接近警报各自的意图。请记住,使用独特的行动意图为每个位置如下:

In order to make your app fire several registered locations, your must first register the broadcast receiver with correct IntentFilter and create the respective Intent for each Proximity Alert. Remember to use unique intent action for each location as follows

.....
IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT + uniqueID);
.....
Intent mIntent = new Intent(PROX_ALERT_INTENT + uniqueID);
......

有关更多信息,你可以阅读的在话题我帖子

For more information, you can read my post on the topic

这篇关于基于服务的多个接近警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆