• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps In BroadcastReceiver get latitude or longtitude of the central point of the alert region that Added

Beyaz

Lurker
Jan 28, 2013
4
0
I searched android api for LocationManager.

I have not seen getProximityAlert() function.

In BroadcastReceiver get latitude or longtitude of the central point of the alert region that Added on ProximityAlert Is this possible ?

I need latitude and longtitude because i should get data on database server in order to show some informations.

[HIGH] private void addProximityAlert(double latitude,double longitude) {


Intent intent = new Intent(PROX_ALERT_INTENT);
intent.putExtra("latitude", latitude);
sendBroadcast(intent);
PendingIntent proximityIntent = PendingIntent.getBroadcast(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
);
// getIns.getInstance().setGoogleMap(this);
IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);

this.registerReceiver(ProximityIntentReceiver, filter);
// registerReceiver(new ProximityIntentReceiver(this), filter);

//

}[/HIGH]

[HIGH] private final BroadcastReceiver ProximityIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
String key = LocationManager.KEY_PROXIMITY_ENTERING;
Boolean entering = intent.getBooleanExtra(key, false);
Toast.makeText(getApplicationContext(),"You are near traffic events",Toast.LENGTH_SHORT).show();
//

//
if (entering)
{ double k= intent.getDoubleExtra("latitude", -1); //I dont //get registered central point here.

displayEventConfirmation();

}
}
}; [/HIGH]
Thanks

Editted: Using intent.getDoubleExtra("latitude", -1); i got DoubleExtra whenever activity start.Problem is that there are more than one proximity alert and i need to get proximityalert which zone is entered that should getDoubleExtra should be catched not on activityStarted.
found this link which doesnot work on me :S
android - How to receive location info when receiving a proximity alert intent? - Stack Overflow
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones