Hi I'm trying to get and update when the phone gets near a location. I've both tried using addProximityAlert and requestLocationUpdates
LocationManager lm =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location l = lm.getLastKnownLocation("gps");
Intent intent = new Intent("eu.mauriziopz.gps.ProximityAlert");
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
lm.addProximityAlert(12, 12, 100, 1000000, pIntent);
This one never fires the intent (which I know works since I can fire it up manually). I tried using a listener but it gets executed only once. No matter how many times I update the gps it never gets called again
ProximityListener pl = new ProximityListener();
lm. requestLocationUpdates("gps", 2000, 10, pl);
this is the code of the activity (called in the first case)
public class ProximityAlert extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Log.d("intent", "Hi");
finish();
}
This is the Listener
public class ProximityListener implements LocationListener {
String DEBUG_TAG = "ProximityListener";
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Log.d(DEBUG_TAG, location.toString());
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
Thanks