0
我正在制作一个应用程序,该应用程序在用户/设备接近其中一个预定义兴趣点时应该显示警报。Android位置感知应用程序 - 设置多个兴趣点而不使用多个监听器
我发现这样做的唯一方法(实际上我的工作就是这样)是为每个感兴趣的点创建一个未决意图(具有唯一的名称)。但我认为这不是在资源方面做到这一点的最佳方式。
是否有可能仅使用一个挂起的intend而不是多个单独的intend来实现此功能?
还有其他更好的方法吗?
在此先感谢
迈克
private void addProximityAlert(double latitude, double longitude, String poiName) {
Bundle extras = new Bundle();
extras.putString("name", poiName);
Intent intent = new Intent(PROX_ALERT_INTENT+poiName);
intent.putExtras(extras);
PendingIntent proximityIntent = PendingIntent.getBroadcast(MainMenu.this, 0, intent, 0);
locationManager.addProximityAlert(
latitude, // the latitude of the central point of the alert region
longitude, // the longitude of the central point of the alert region
POINT_RADIUS, // the radius of the central point of the alert region, in meters
PROX_ALERT_EXPIRATION, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration
proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected
);
IntentFilter filter = new IntentFilter(poiName);
registerReceiver(new ProximityIntentReceiver(), filter);
}
}
向我们展示一个代码片段...你对待处理意图做什么? – 2011-02-08 23:52:23