6
근접 경보를 여러 개 만들려고 노력 중입니다 ...broadcastReceiver가 여러 브로드 캐스트를 잡을 수 있습니까?
브로드 캐스트 수신기가 덮어 써서 마지막 브로드 캐스트 만 처리하고 있다고 생각합니다. 따라서 의도가 마지막으로 생성 된 의도 한 것만으로 두 점을 알리면 경고가 생성됩니다.
요청 코드를 사용해야한다고 읽었지 만 그 방법을 모르는 ...
보류중인 의도와 방송 수신기를 설정하기위한 나의 방법 ...
private void addProximityAlert(double latitude, double longitude, String poiName, String intentfilter) {
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, requestCode, 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
);
requestCode++;
IntentFilter filter = new IntentFilter(intentfilter);
registerReceiver(new ProximityIntentReceiver(), filter);
}
내 브로드 캐스트 리시버 클래스
public class ProximityIntentReceiver extends BroadcastReceiver {
private static final int NOTIFICATION_ID = 1000;
@Override
public void onReceive(Context context, Intent intent) {
String key = LocationManager.KEY_PROXIMITY_ENTERING;
Boolean entering = intent.getBooleanExtra(key, false);
if (entering) {
Log.d(getClass().getSimpleName(), "entering");
}
else {
Log.d(getClass().getSimpleName(), "exiting");
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, null, 0);
Notification notification = createNotification();
notification.setLatestEventInfo(context,
"Proximity Alert!", "You are approaching: " +intent.getExtras().get("name"), pendingIntent);
//here-------------------------------------
notificationManager.notify(NOTIFICATION_ID, notification);
}
private Notification createNotification() {
Notification notification = new Notification();
notification.icon = R.drawable.androidmarker;
notification.when = System.currentTimeMillis();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.flags |= Notification.FLAG_INSISTENT;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.ledARGB = Color.WHITE;
notification.ledOnMS = 300;
notification.ledOffMS = 1500;
return notification;
}
}
제발 나를 도울 수 있니? 정말 이걸로 붙어있어 ...
어떤 도움을 정말 고맙게 생각합니다 !!! 난 결국 일을 가지고
그냥리스 내가 원래 코드에 대한 업데이트를 게시했다는 것을 알 수 있습니다. GitHub에 대한 전체 예제가 포함되어 있습니다. http : //www.gauntface.co.uk/pages/blog/2010/12/28/how-to-multiple-proximity-alerts-in-android/ –
알리미? 내 것은 계속해서 건물을 짓는다. : – deucalion0
그동안 잠시 동안 미안하게 생각한 것을 기억하지 못합니다. – mixkat