我正在开发一个使用接近警报检测进入和退出区域的应用程序。我只收到进入但没有退出的通知。我正在使用以下代码,
pIntent2 = PendingIntent.getBroadcast(getApplicationContext(), 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
locMgr.addProximityAlert(lat, lon, radius, 60000L, pIntent2);
proxReceiver = new ProximityReceiver();
IntentFilter iFilter = new IntentFilter(PROX_ALERT);
iFilter.addDataScheme("geo");
registerReceiver(proxReceiver, iFilter);
//广播接收器
public class ProximityReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent intent) {
if (intent.getData() != null) {
Log.v(TAG, intent.getData().toString());
}
Bundle extras = intent.getExtras();
if (extras != null) {
final String key = LocationManager.KEY_PROXIMITY_ENTERING;
final Boolean entering = intent.getBooleanExtra(key, false);
if (entering) {
Toast.makeText(arg0, "entering", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(arg0, "exiting", Toast.LENGTH_SHORT).show();
}
}
}
}
任何人请帮助。提前致谢。