Domanda

Sto realizzando un'app che dovrebbe mostrare avvisi ogni volta che l'utente/dispositivo si avvicina a uno dei punti di interesse predefiniti.

L'unico modo in cui ho trovato per farlo (in effetti l'ho fatto funzionare in quel modo) è creare un intento in sospeso (con un nome unico) per ogni singolo punto di interesse. Ma penso che non sia il modo migliore per farlo in termini di risorse.

È possibile ottenere tale funzionalità usando solo un intenso in corso invece di più separati?

C'è qualche altro modo migliore di farlo?

Grazie in anticipo

Mike


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);

    }
}

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top