1. Download our Official Android App: Forums for Android!

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

Discussion in 'Android Development' started by Beyaz, Jan 28, 2013.

  1. Beyaz

    Beyaz Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jan 28, 2013

    Jan 28, 2013
    4
    0
    5
    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
     

    Advertisement

  2. Beyaz

    Beyaz Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jan 28, 2013

    Jan 28, 2013
    4
    0
    5
    Guys im really stuck on this. If anyone help me on that i appreciate that
     

Share This Page

Loading...