Android 基于服务的多个接近警报
我有我的应用程序,当用户进入指定的无线电时,它使用ProximityAlerts启动 我的代理人启动了一项服务,向我敬酒,告诉我我已经进入了活动的指定电台 问题在于,我无法让我的应用程序触发几个已注册的位置,它只对最后一个已注册的位置作出反应,而忽略先前注册的事件Android 基于服务的多个接近警报,android,service,Android,Service,我有我的应用程序,当用户进入指定的无线电时,它使用ProximityAlerts启动 我的代理人启动了一项服务,向我敬酒,告诉我我已经进入了活动的指定电台 问题在于,我无法让我的应用程序触发几个已注册的位置,它只对最后一个已注册的位置作出反应,而忽略先前注册的事件 需要帮忙吗?我见过有人使用广播接收器,但就我而言,我使用的是服务。您是否考虑过使用广播接收器,然后从接收器启动服务 当我第一次使用它们时,我发现系统缓存了结果,所以不得不设置一个ID(文档声称不使用)。通过这样做,意图不会被缓存,我获
需要帮忙吗?我见过有人使用广播接收器,但就我而言,我使用的是服务。您是否考虑过使用广播接收器,然后从接收器启动服务 当我第一次使用它们时,我发现系统缓存了结果,所以不得不设置一个ID(文档声称不使用)。通过这样做,意图不会被缓存,我获得了处理多个接近警报的适当信息
源代码可通过github获得(见本文底部)您是否考虑过使用广播接收器,然后从接收器启动服务 当我第一次使用它们时,我发现系统缓存了结果,所以不得不设置一个ID(文档声称不使用)。通过这样做,意图不会被缓存,我获得了处理多个接近警报的适当信息
源代码可通过github获得(参见本文底部)这里有几点需要说明:
int uniqueID = <unique_id_for_location>;
String intentAction = "PROXIMITY_ALERT." + uniqueID;
PendingIntent proximityIntent = PendingIntent.getBroadcast(getApplicationContext(),
uniqueID, new Intent(intentAction), PendingIntent.FLAG_CANCEL_CURRENT);
这里,ProximityEndReceiver是您创建的BroadcastReceiver类的名称。这里有几点需要说明:
int uniqueID = <unique_id_for_location>;
String intentAction = "PROXIMITY_ALERT." + uniqueID;
PendingIntent proximityIntent = PendingIntent.getBroadcast(getApplicationContext(),
uniqueID, new Intent(intentAction), PendingIntent.FLAG_CANCEL_CURRENT);
这里,ProximityEndReceiver是您创建的BroadcastReceiver类的名称。要构建具有接近警报的Android应用程序,主要成分是Broadcast Receiver、Intent、PendingEvent和AddProximityAlert 工作流程应如下所示:-
.....
IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT + uniqueID);
.....
Intent mIntent = new Intent(PROX_ALERT_INTENT + uniqueID);
......
要了解更多信息,您可以阅读主题来构建一个带有邻近警报的Android应用程序,主要成分是广播接收器、意图、PendingEvent和AddProximityAlert 工作流程应如下所示:-
.....
IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT + uniqueID);
.....
Intent mIntent = new Intent(PROX_ALERT_INTENT + uniqueID);
......
有关更多信息,您可以阅读主题这都是关于PendingEvent中的请求id的,您可以为PendingEvent分配一个请求id。如果您的第一个服务使用请求id 1,则表示第二个服务使用请求id 2。因此,不会终止第一个服务,并且该服务同时发生 我在pending intent中用作请求id的计数
int COUNT=Integer.parseInt(some_text.getText().toString());
if(COUNT==1)
{
PendingIntent proxi_pi=PendingIntent.getService(class_name.this,COUNT,service_class_intent,Intent.FLAG_ACTIVITY_NEW_TASK);
location_manager.addProximityAlert(location.getLatitude(), location.getLongitude(), radius, -1, proxi_pi);
}
else if(COUNT==2)
{
PendingIntent proxi_pi=PendingIntent.getService(class_name.this,count,service_class_intent,Intent.FLAG_ACTIVITY_NEW_TASK);
location_manager.addProximityAlert(location.getLatitude(), location.getLongitude(), radius, -1, proxi_pi);
}
else if(COUNT==so..on){
}
我希望这对您有所帮助。这都是关于PendingEvent中的请求id,您为PendingEvent分配了一个请求id。。如果您的第一个服务使用请求id 1,则表示第二个服务使用请求id 2。。因此不会终止第一个服务,并且该服务同时发生 我在pending intent中用作请求id的计数
int COUNT=Integer.parseInt(some_text.getText().toString());
if(COUNT==1)
{
PendingIntent proxi_pi=PendingIntent.getService(class_name.this,COUNT,service_class_intent,Intent.FLAG_ACTIVITY_NEW_TASK);
location_manager.addProximityAlert(location.getLatitude(), location.getLongitude(), radius, -1, proxi_pi);
}
else if(COUNT==2)
{
PendingIntent proxi_pi=PendingIntent.getService(class_name.this,count,service_class_intent,Intent.FLAG_ACTIVITY_NEW_TASK);
location_manager.addProximityAlert(location.getLatitude(), location.getLongitude(), radius, -1, proxi_pi);
}
else if(COUNT==so..on){
}
我希望这对您有所帮助。Hi GaunFace,是否可以使用
PendingEvent.getService()
方法生成多个近距离警报?Hi GaunFace,是否可以使用PendingEvent.getService()
方法生成多个近距离警报?