addProximityAlert() doesn't fire intent

by Joe77 » Tue, 06 Oct 2009 01:17:56 GMT

Sponsored Links

I am new to Android development and I am trying to write an App that
uses the addProximityAlert() method. I know my intent / intent-filters
work (as I can manually fire the intent) however I cannot seem to get
addProximityAlert to fire an intent. I've searched on various forums
and read the API docs numerous times however have not been able to
determine what is wrong with my code. Any ideas?

package com.example.gpsprox;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class GpsProx extends Activity implements OnClickListener {

private LocationManager lm;
private Proximity prox;
String phoneNo;
String message;
double latitude;
double longitude;
float radius;

private static final String PROXIMITY_ALERT =

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

//---use the LocationManager class to obtain GPS locations---
lm = (LocationManager)

// Use addProximityAlert public method of locationmanager

// Test Latitude / Longitude is at corner of Bute Gardens and
the broadway.

latitude = 51.4935684;
longitude = -0.2223873;
radius = 0;
// Context context;

Intent intent = new Intent(PROXIMITY_ALERT);

PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext
(), 0, intent, 0);

// sendBroadcast(intent);

lm.addProximityAlert(latitude, longitude, radius, -1, pi);

IntentFilter filter = new IntentFilter(PROXIMITY_ALERT);
registerReceiver(new Proximity(), filter);

Button button = (Button)findViewById(;

"Got here!",


// Implement the OnClickListener callback
public void onClick(View v) {

// lm.removeProximityAlert(GpsProx.pi);



public class Proximity extends BroadcastReceiver

public void onReceive(Context context, Intent
intent) {
// TODO Auto-generated method stub

"Got her

Other Threads

1. Playing a video file from resource.

Hi All,

success. I have used this code

                mPreview = (SurfaceView) findViewById(;
                holder = mPreview.getHolder();

// Create a new media player and set the listeners
                mMediaPlayer = MediaPlayer.create(this, R.raw.lucky);

} catch (Exception e) {

        Log.e(TAG, "error: " + e.getMessage(), e);


public void onBufferingUpdate(MediaPlayer arg0, int percent) {
Log.d(TAG, "onBufferingUpdate percent:" + percent);


public void onCompletion(MediaPlayer arg0) {
Log.d(TAG, "onCompletion called");


public void onPrepared(MediaPlayer mediaplayer) {
                Log.d(TAG, "onPrepared called");
mVideoWidth = mMediaPlayer.getVideoWidth();
mVideoHeight = mMediaPlayer.getVideoHeight();
if (mVideoWidth != 0 && mVideoHeight != 0) {
  holder.setFixedSize(mVideoWidth, mVideoHeight);


while I try to run the above I can hear the audio of video file but no
video. please advise .
I m trying to play
but having no luck please advise me .



2. Global search always shows "More results... XXX (n)" for 3rd party application?

Hi Dianne,

Works as expected. Thanks for the explanation!

Best regards,
Andrew Zhang


3. Global search always shows "More results... XXX (n)" for 3rd party application?

4. Why Update buffering is always 0% when mediaplayer play the rtsp ?

5. How can I extends InputMethodService and using its feature without setting system keyboard??

6. ]

7. Migration of iphone鈥檚 applica tion to Android